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

View File

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

View File

@ -189,18 +189,18 @@
</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="webSiteLeftCode">
<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 id="webSiteRightCode">
<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>