Jelajahi Sumber

问卷发布页面和代码1

admin 2 tahun lalu
induk
melakukan
4bab936036

+ 1 - 1
common/pom.xml

@@ -276,7 +276,7 @@
 			<groupId>junit</groupId>
 			<artifactId>junit</artifactId>
 		</dependency>
-		
+
 	</dependencies>
 	
 	<developers>  

+ 56 - 0
common/src/main/java/com/jeesite/common/utils/ip/IpUtil.java

@@ -0,0 +1,56 @@
+package com.jeesite.common.utils.ip;
+
+
+import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.StringUtils;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * 获取用户访问ip地址
+ */
+public class IpUtil {
+    public static String getIpAddress(HttpServletRequest request) {
+        String ip = request.getHeader("x-forwarded-for");
+        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+            ip = request.getHeader("Proxy-Client-IP");
+        }
+        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+            ip = request.getHeader("WL-Proxy-Client-IP");
+        }
+        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+            ip = request.getHeader("HTTP_CLIENT_IP");
+        }
+        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+            ip = request.getHeader("HTTP_X_FORWARDED_FOR");
+        }
+        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+            ip = request.getRemoteAddr();
+        }
+        // 获取到多个ip时取第一个作为客户端真实ip
+        if (StringUtils.isNotEmpty(ip) && ip.contains(",")) {
+        	String[] ipArray = ip.split(",");
+        	if (ArrayUtils.isNotEmpty(ipArray)) {
+        		ip = ipArray[0];
+        	}
+        }
+        return ip;
+    }
+
+    public static String getIpAddr(HttpServletRequest request) {
+        String ip = request.getHeader("x-forwarded-for");
+        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+            ip = request.getHeader("Proxy-Client-IP");
+        }
+        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+            ip = request.getHeader("WL-Proxy-Client-IP");
+        }
+        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+            ip = request.getRemoteAddr();
+        }
+        if(ip != null) {
+            ip=ip.split(",")[0];
+        }
+        return ip;
+    }
+}

+ 19 - 0
web/src/main/java/com/jeesite/modules/admin/wenjuan/web/getIPdemo.java

@@ -0,0 +1,19 @@
+package com.jeesite.modules.admin.wenjuan.web;
+
+import java.net.Inet4Address;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+public class getIPdemo {
+
+    public static void main(String[] args) {
+
+        try {
+            InetAddress ip4 = Inet4Address.getLocalHost();
+            System.out.println(ip4.getHostAddress());
+        } catch (UnknownHostException e) {
+            e.printStackTrace();
+        }
+    }
+
+}

+ 1 - 1
web/src/main/resources/views/modules/admin/wenjuan/adminQuestionItemForm.html

@@ -132,7 +132,7 @@ $("#adminQuestionOptionDataGrid").dataGrid({
 		},*/
 		// {header:'${text("得票数")}', name:'count', width:150, editable:true, edittype:'text', editoptions:{'class':'form-control digits'}},
 		// {header:'${text("排序")}', name:'seq', width:150, editable:true, edittype:'text', editoptions:{'class':'form-control digits'}},
-		{header:'${text("备注")}', name:'remarks', width:150, editable:true, edittype:'textarea', editoptions:{'maxlength':'255', 'class':'form-control', 'rows':'1'}},
+		{header:'${text("备注  (最多填写100字)")}', name:'remarks', width:150, editable:true, edittype:'textarea', editoptions:{'maxlength':'255', 'class':'form-control', 'rows':'1'}},
 		{header:'${text("操作")}', name:'actions', width:80, align:'center', formatter: function(val, obj, row, act){
 			var actions = [];
 			if (val == 'new'){

+ 1 - 1
web/src/main/resources/views/modules/admin/wenjuan/adminQuestionnaireSurveyForm.html

@@ -223,7 +223,7 @@
                 editoptions: {'class': 'form-control digits'}
             },*/
             {
-                header: '${text("备注")}',
+                header: '${text("备注 (最多填写100字)")}',
                 name: 'remarks',
                 width: 150,
                 editable: true,