修改WEB组件生成答卷地址问题

This commit is contained in:
keyuan 2021-04-25 21:29:37 +08:00
parent 0e868bf85f
commit 9e5e95aee1
3 changed files with 19 additions and 21 deletions

View File

@ -14,7 +14,7 @@ public class IPService {
private IPSeeker ipSeeker; private IPSeeker ipSeeker;
public String getIp(HttpServletRequest request) { public String getIp(HttpServletRequest request) {
//Http Header:X-Forwarded-For //Http Header:X-Forwarded-For
String ip = request.getHeader("X-Forwarded-For"); String ip = request.getHeader("X-Forwarded-For");
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
@ -44,27 +44,26 @@ public class IPService {
try { try {
InetAddress inetAddress = InetAddress.getLocalHost(); InetAddress inetAddress = InetAddress.getLocalHost();
ip=inetAddress.getHostAddress(); ip=inetAddress.getHostAddress();
if(ip!=null && ip.length()>15){ //"***.***.***.***".length() = 15 if(ip!=null && ip.length()>15){ //"***.***.***.***".length() = 15
if(ip.indexOf(",")>0){ if(ip.indexOf(",")>0){
ip = ip.substring(0,ip.indexOf(",")); ip = ip.substring(0,ip.indexOf(","));
} }
} }
System.out.println(ip);
} catch (UnknownHostException e) { } catch (UnknownHostException e) {
// e.printStackTrace(); // e.printStackTrace();
} }
} }
return ip; return ip;
} }
public String replaceIPv6LocalIp(String ip){ public String replaceIPv6LocalIp(String ip){
if("0:0:0:0:0:0:0:1".equals(ip)){ if("0:0:0:0:0:0:0:1".equals(ip)){
ip="127.0.0.1"; ip="127.0.0.1";
} }
return ip; return ip;
} }
public String getCountry(String ip) { public String getCountry(String ip) {
if(ip==null){ if(ip==null){
return ""; return "";
@ -74,7 +73,7 @@ public class IPService {
/** /**
* 根据IP查出此ip所在的城市 * 根据IP查出此ip所在的城市
* *
* @param ip * @param ip
* @return * @return
*/ */
@ -87,7 +86,7 @@ public class IPService {
/** /**
* 根据 getCountry(ip);得到的地址得到城市 * 根据 getCountry(ip);得到的地址得到城市
* *
* @param country * @param country
* @return * @return
*/ */
@ -109,7 +108,7 @@ public class IPService {
/** /**
* 根据 request对象得到数据请求者所在的城市 * 根据 request对象得到数据请求者所在的城市
* *
* @param request * @param request
* @return * @return
*/ */
@ -121,7 +120,7 @@ public class IPService {
city = city.replaceAll("清华大学.*", "北京"); city = city.replaceAll("清华大学.*", "北京");
return city; return city;
} }
public static void main(String[] args) { public static void main(String[] args) {
String ip="111.206.20.59, 123.151.42.46, 121.42.17.215"; String ip="111.206.20.59, 123.151.42.46, 121.42.17.215";
System.out.println(ip.substring(0,ip.indexOf(","))); System.out.println(ip.substring(0,ip.indexOf(",")));

View File

@ -43,13 +43,12 @@ public class LoginAction extends ActionSupport {
private FormAuthenticationWithLockFilter formAuthFilter; private FormAuthenticationWithLockFilter formAuthFilter;
@Autowired @Autowired
protected AccountManager accountManager; protected AccountManager accountManager;
public String login() throws Exception { public String login() throws Exception {
System.out.println("username1-1");
HttpServletRequest request = Struts2Utils.getRequest(); HttpServletRequest request = Struts2Utils.getRequest();
HttpServletResponse response = Struts2Utils.getResponse(); HttpServletResponse response = Struts2Utils.getResponse();
Subject subject = SecurityUtils.getSubject(); Subject subject = SecurityUtils.getSubject();
boolean isAuth = subject.isAuthenticated(); boolean isAuth = subject.isAuthenticated();
// 返回成功与否 // 返回成功与否
@ -80,7 +79,7 @@ public class LoginAction extends ActionSupport {
error="ExcessiveAttemptsException"; error="ExcessiveAttemptsException";
} }
} }
//PrintWriter writer = response.getWriter(); //PrintWriter writer = response.getWriter();
//writer.write(isAuth + ","+error);//此种方式在$.getJson()进行仿问时会出现不执行回调函数 //writer.write(isAuth + ","+error);//此种方式在$.getJson()进行仿问时会出现不执行回调函数
// System.out.println(isAuth+","+error); // System.out.println(isAuth+","+error);
response.setContentType("text/plain");// 1.设置返回响应的类型 response.setContentType("text/plain");// 1.设置返回响应的类型
@ -100,7 +99,7 @@ public class LoginAction extends ActionSupport {
return "login"; return "login";
} }
/* 给某个锁定的账号开锁,管理员使用 */ /* 给某个锁定的账号开锁,管理员使用 */
public String lockout() throws Exception { public String lockout() throws Exception {
HttpServletRequest request=Struts2Utils.getRequest(); HttpServletRequest request=Struts2Utils.getRequest();
HttpServletResponse response=Struts2Utils.getResponse(); HttpServletResponse response=Struts2Utils.getResponse();
@ -108,7 +107,7 @@ public class LoginAction extends ActionSupport {
//确认有没账号 //确认有没账号
boolean isup=false; boolean isup=false;
String error="用户不存在"; String error="用户不存在";
if(username!=null){ if(username!=null){
// User user=accountManager.findUserByLoginName(username); // User user=accountManager.findUserByLoginName(username);
User user = accountManager.findUserByLoginNameOrEmail(username); User user = accountManager.findUserByLoginNameOrEmail(username);
@ -120,9 +119,9 @@ public class LoginAction extends ActionSupport {
response.getWriter().write(isup?username+"解锁成功":username+""+error); response.getWriter().write(isup?username+"解锁成功":username+""+error);
return null; return null;
} }
public String register() throws Exception { public String register() throws Exception {
return ""; return "";
} }

View File

@ -189,18 +189,18 @@
</div> </div>
</div> </div>
<div id="compStyle1" style="display: none;"><!-- DIAOWEN.NET Button BEGIN --><div style="position: fixed;right: 0px;top: 100px;z-index: 9999;"><a href="http://www.diaowen.net/wenjuan/${survey.sid }.html" style="background: #1C658B;width: 15px;height: 100px;background: #8CBCD1;display: block;padding: 5px;padding-top: 10px;font-weight: bold;color: white! important;cursor: pointer;float: right;vertical-align: middle;text-decoration: none;font-size: 12px;-moz-border-radius-topleft: 5px; -webkit-border-top-left-radius: 5px;-khtml-border-top-left-radius: 5px;border-top-left-radius: 5px;-moz-border-radius-bottomleft: 5px; -webkit-border-bottom-left-radius: 5px;-khtml-border-bottom-left-radius: 5px; border-bottom-left-radius: 5px;">问卷调查</a></div><!-- DIAOWEN.NET Button END --></div> <div id="compStyle1" style="display: none;"><!-- DIAOWEN.NET Button BEGIN --><div style="position: fixed;right: 0px;top: 100px;z-index: 9999;"><a href="${baseUrl }/dwsurvey/${survey.sid }.html" style="background: #1C658B;width: 15px;height: 100px;background: #8CBCD1;display: block;padding: 5px;padding-top: 10px;font-weight: bold;color: white! important;cursor: pointer;float: right;vertical-align: middle;text-decoration: none;font-size: 12px;-moz-border-radius-topleft: 5px; -webkit-border-top-left-radius: 5px;-khtml-border-top-left-radius: 5px;border-top-left-radius: 5px;-moz-border-radius-bottomleft: 5px; -webkit-border-bottom-left-radius: 5px;-khtml-border-bottom-left-radius: 5px; border-bottom-left-radius: 5px;">问卷调查</a></div><!-- DIAOWEN.NET Button END --></div>
<div id="priviewContent" class="priviewContentFixed"> <div id="priviewContent" class="priviewContentFixed">
<div id="webSiteLeftCode"> <div id="webSiteLeftCode">
<div id="webSiteFixedLeft" class="websiteFixed" style="position: fixed;left: 0px;top: 520px;z-index: 9999;display: none;"> <div id="webSiteFixedLeft" class="websiteFixed" style="position: fixed;left: 0px;top: 520px;z-index: 9999;display: none;">
<a class="websiteAId" href="http://www.diaowen.net/wenjuan/${survey.sid }.html" style="background: #1C658B;width: 15px;background: #8CBCD1;display: block;padding: 5px;padding-top: 10px;padding-bottom:10px;font-weight: bold;color: white;cursor: pointer;float: right;vertical-align: middle;text-decoration: none;font-size: 12px;-moz-border-radius-topright: 5px;-webkit-border-top-right-radius: 5px;-khtml-border-top-right-radius: 5px;border-top-right-radius: 5px;-moz-border-radius-bottomright: 5px;-webkit-border-bottom-right-radius: 5px;-khtml-border-bottom-right-radius: 5px;border-bottom-right-radius: 5px;">问卷调查</a> <a class="websiteAId" href="${baseUrl }/dwsurvey/${survey.sid }.html" style="background: #1C658B;width: 15px;background: #8CBCD1;display: block;padding: 5px;padding-top: 10px;padding-bottom:10px;font-weight: bold;color: white;cursor: pointer;float: right;vertical-align: middle;text-decoration: none;font-size: 12px;-moz-border-radius-topright: 5px;-webkit-border-top-right-radius: 5px;-khtml-border-top-right-radius: 5px;border-top-right-radius: 5px;-moz-border-radius-bottomright: 5px;-webkit-border-bottom-right-radius: 5px;-khtml-border-bottom-right-radius: 5px;border-bottom-right-radius: 5px;">问卷调查</a>
</div> </div>
</div> </div>
<div id="webSiteRightCode"> <div id="webSiteRightCode">
<div id="webSiteFixedRight" class="websiteFixed" style="position: fixed;right: 0px;top: 520px;z-index: 9999;"> <div id="webSiteFixedRight" class="websiteFixed" style="position: fixed;right: 0px;top: 520px;z-index: 9999;">
<a class="websiteAId" href="http://www.diaowen.net/wenjuan/${survey.sid }.html" style="background: #1C658B;width: 15px;background: #8CBCD1;display: block;padding: 5px;padding-top: 10px;padding-bottom:10px;font-weight: bold;color: white;cursor: pointer;float: right;vertical-align: middle;text-decoration: none;font-size: 12px;-moz-border-radius-topleft: 5px; -webkit-border-top-left-radius: 5px;-khtml-border-top-left-radius: 5px;border-top-left-radius: 5px;-moz-border-radius-bottomleft: 5px; -webkit-border-bottom-left-radius: 5px;-khtml-border-bottom-left-radius: 5px; border-bottom-left-radius: 5px;">问卷调查</a> <a class="websiteAId" href="${baseUrl }/dwsurvey/${survey.sid }.html" style="background: #1C658B;width: 15px;background: #8CBCD1;display: block;padding: 5px;padding-top: 10px;padding-bottom:10px;font-weight: bold;color: white;cursor: pointer;float: right;vertical-align: middle;text-decoration: none;font-size: 12px;-moz-border-radius-topleft: 5px; -webkit-border-top-left-radius: 5px;-khtml-border-top-left-radius: 5px;border-top-left-radius: 5px;-moz-border-radius-bottomleft: 5px; -webkit-border-bottom-left-radius: 5px;-khtml-border-bottom-left-radius: 5px; border-bottom-left-radius: 5px;">问卷调查</a>
</div> </div>
</div> </div>
</div> </div>