1.增加增强文本管控的ip类校验

2.将ip地址格式校验提示语提出至国际化配置
This commit is contained in:
chenjinsong
2018-04-08 17:07:32 +08:00
parent aaf8dd5afb
commit 1828b726ba
7 changed files with 59 additions and 28 deletions

View File

@@ -125,7 +125,6 @@ public class SystemServiceController extends BaseController {
public String delete(Model model, SystemServiceInfo systemServiceInfo, HttpServletRequest request, HttpServletResponse response) {
//增加后台校验,当数据是初始数据时不允许删除
if(systemServiceInfo.getIsInitianlize().intValue() == 1) {
addMessage(model, "delete_failed");
return "/error/403";
}

View File

@@ -36,14 +36,14 @@
<div class="col-md-6">
<c:choose>
<c:when test="${mainTableType eq '1' and otherTable==null}">
<select name="ipCfg[${mainTable}].ipType" class="ipType selectpicker show-tick form-control">
<select name="ipCfg[${mainTable}].ipType" class="ipType selectpicker show-tick form-control required">
<option value="" ><spring:message code="select"/></option>
<option value="4" <c:if test="${_cfg.ipCfg[mainTable].ipType==4}">selected</c:if> >V4</option>
<option value="6" <c:if test="${_cfg.ipCfg[mainTable].ipType==6}">selected</c:if>>V6</option>
</select>
</c:when>
<c:when test="${otherTable!=null and otherTable.tableType eq '1'}">
<select name="ipCfg[${otherTable.tableName}].ipType" class="ipType selectpicker show-tick form-control" title=<spring:message code="select"/>>
<select name="ipCfg[${otherTable.tableName}].ipType" class="ipType selectpicker show-tick form-control required" title=<spring:message code="select"/>>
<option value="" ><spring:message code="select"/></option>
<option value="4" <c:if test="${_cfg.ipCfg[otherTable.tableName].ipType==4}">selected</c:if> >V4</option>
<option value="6" <c:if test="${_cfg.ipCfg[otherTable.tableName].ipType==6}">selected</c:if>>V6</option>
@@ -69,10 +69,10 @@
<div class="col-md-6">
<c:choose>
<c:when test="${mainTableType eq '1' and otherTable==null}">
<input class="form-control" type="text" name="ipCfg[${mainTable}].srcIp" value="${_cfg.ipCfg[mainTable].srcIp}">
<input class="form-control required" type="text" name="ipCfg[${mainTable}].srcIp" value="${_cfg.ipCfg[mainTable].srcIp}">
</c:when>
<c:when test="${otherTable!=null and otherTable.tableType eq '1'}">
<input class="form-control" type="text" name="ipCfg[${otherTable.tableName}].srcIp" value="${_cfg.ipCfg[otherTable.tableName].srcIp}">
<input class="form-control required" type="text" name="ipCfg[${otherTable.tableName}].srcIp" value="${_cfg.ipCfg[otherTable.tableName].srcIp}">
</c:when>
</c:choose>
</div>
@@ -92,10 +92,10 @@
<div class="col-md-6">
<c:choose>
<c:when test="${mainTableType eq '1' and otherTable==null}">
<input class="form-control" type="text" name="ipCfg[${mainTable}].srcIpMask" value="${_cfg.ipCfg[mainTable].srcIpMask}">
<input class="form-control required" type="text" name="ipCfg[${mainTable}].srcIpMask" value="${_cfg.ipCfg[mainTable].srcIpMask}">
</c:when>
<c:when test="${otherTable!=null and otherTable.tableType eq '1'}">
<input class="form-control" type="text" name="ipCfg[${otherTable.tableName}].srcIpMask" value="${_cfg.ipCfg[otherTable.tableName].srcIpMask}">
<input class="form-control required" type="text" name="ipCfg[${otherTable.tableName}].srcIpMask" value="${_cfg.ipCfg[otherTable.tableName].srcIpMask}">
</c:when>
</c:choose>
</div>
@@ -118,10 +118,10 @@
<div class="col-md-6">
<c:choose>
<c:when test="${mainTableType eq '1' and otherTable==null}">
<input class="form-control" type="text" name="ipCfg[${mainTable}].srcPort" value="${_cfg.ipCfg[mainTable].srcPort}">
<input class="form-control required" type="text" name="ipCfg[${mainTable}].srcPort" value="${_cfg.ipCfg[mainTable].srcPort}">
</c:when>
<c:when test="${otherTable!=null and otherTable.tableType eq '1'}">
<input class="form-control" type="text" name="ipCfg[${otherTable.tableName}].srcPort" value="${_cfg.ipCfg[otherTable.tableName].srcPort}">
<input class="form-control required" type="text" name="ipCfg[${otherTable.tableName}].srcPort" value="${_cfg.ipCfg[otherTable.tableName].srcPort}">
</c:when>
</c:choose>
</div>
@@ -141,10 +141,10 @@
<div class="col-md-6">
<c:choose>
<c:when test="${mainTableType eq '1' and otherTable==null}">
<input class="form-control" type="text" name="ipCfg[${mainTable}].srcPortMask" value="${_cfg.ipCfg[mainTable].srcPortMask}">
<input class="form-control required" type="text" name="ipCfg[${mainTable}].srcPortMask" value="${_cfg.ipCfg[mainTable].srcPortMask}">
</c:when>
<c:when test="${otherTable!=null and otherTable.tableType eq '1'}">
<input class="form-control" type="text" name="ipCfg[${otherTable.tableName}].srcPortMask" value="${_cfg.ipCfg[otherTable.tableName].srcPortMask}">
<input class="form-control required" type="text" name="ipCfg[${otherTable.tableName}].srcPortMask" value="${_cfg.ipCfg[otherTable.tableName].srcPortMask}">
</c:when>
</c:choose>
</div>
@@ -166,10 +166,10 @@
<div class="col-md-6">
<c:choose>
<c:when test="${mainTableType eq '1' and otherTable==null}">
<input class="form-control" type="text" name="ipCfg[${mainTable}].dstIp" value="${_cfg.ipCfg[mainTable].dstIp}">
<input class="form-control required" type="text" name="ipCfg[${mainTable}].dstIp" value="${_cfg.ipCfg[mainTable].dstIp}">
</c:when>
<c:when test="${otherTable!=null and otherTable.tableType eq '1'}">
<input class="form-control" type="text" name="ipCfg[${otherTable.tableName}].dstIp" value="${_cfg.ipCfg[otherTable.tableName].dstIp}">
<input class="form-control required" type="text" name="ipCfg[${otherTable.tableName}].dstIp" value="${_cfg.ipCfg[otherTable.tableName].dstIp}">
</c:when>
</c:choose>
</div>
@@ -189,10 +189,10 @@
<div class="col-md-6">
<c:choose>
<c:when test="${mainTableType eq '1' and otherTable==null}">
<input class="form-control" type="text" name="ipCfg[${mainTable}].dstIpMask" value="${_cfg.ipCfg[mainTable].dstIpMask}">
<input class="form-control required" type="text" name="ipCfg[${mainTable}].dstIpMask" value="${_cfg.ipCfg[mainTable].dstIpMask}">
</c:when>
<c:when test="${otherTable!=null and otherTable.tableType eq '1'}">
<input class="form-control" type="text" name="ipCfg[${otherTable.tableName}].dstIpMask" value="${_cfg.ipCfg[otherTable.tableName].dstIpMask}">
<input class="form-control required" type="text" name="ipCfg[${otherTable.tableName}].dstIpMask" value="${_cfg.ipCfg[otherTable.tableName].dstIpMask}">
</c:when>
</c:choose>
</div>
@@ -214,10 +214,10 @@
<div class="col-md-6">
<c:choose>
<c:when test="${mainTableType eq '1' and otherTable==null}">
<input class="form-control" type="text" name="ipCfg[${mainTable}].dstPort" value="${_cfg.ipCfg[mainTable].dstPort}">
<input class="form-control required" type="text" name="ipCfg[${mainTable}].dstPort" value="${_cfg.ipCfg[mainTable].dstPort}">
</c:when>
<c:when test="${otherTable!=null and otherTable.tableType eq '1'}">
<input class="form-control" type="text" name="ipCfg[${otherTable.tableName}].dstPort" value="${_cfg.ipCfg[otherTable.tableName].dstPort}">
<input class="form-control required" type="text" name="ipCfg[${otherTable.tableName}].dstPort" value="${_cfg.ipCfg[otherTable.tableName].dstPort}">
</c:when>
</c:choose>
</div>
@@ -237,10 +237,10 @@
<div class="col-md-6">
<c:choose>
<c:when test="${mainTableType eq '1' and otherTable==null}">
<input class="form-control" type="text" name="ipCfg[${mainTable}].dstPortMask" value="${_cfg.ipCfg[mainTable].dstPortMask}">
<input class="form-control required" type="text" name="ipCfg[${mainTable}].dstPortMask" value="${_cfg.ipCfg[mainTable].dstPortMask}">
</c:when>
<c:when test="${otherTable!=null and otherTable.tableType eq '1'}">
<input class="form-control" type="text" name="ipCfg[${otherTable.tableName}].dstPortMask" value="${_cfg.ipCfg[otherTable.tableName].dstPortMask}">
<input class="form-control required" type="text" name="ipCfg[${otherTable.tableName}].dstPortMask" value="${_cfg.ipCfg[otherTable.tableName].dstPortMask}">
</c:when>
</c:choose>
</div>
@@ -262,14 +262,14 @@
<div class="col-md-6">
<c:choose>
<c:when test="${mainTableType eq '1' and otherTable==null}">
<select name="ipCfg[${mainTable}].direction" class="selectpicker show-tick form-control" title=<spring:message code="select"/>>
<select name="ipCfg[${mainTable}].direction" class="selectpicker show-tick form-control required" title=<spring:message code="select"/>>
<option value="" ><spring:message code="select"/></option>
<option value="0" <c:if test="${_cfg.ipCfg[mainTable].direction==0}">selected</c:if>>0</option>
<option value="1" <c:if test="${_cfg.ipCfg[mainTable].direction==1}">selected</c:if>>1</option>
</select>
</c:when>
<c:when test="${otherTable!=null and otherTable.tableType eq '1'}">
<select name="ipCfg[${otherTable.tableName}].direction" class="selectpicker show-tick form-control" title=<spring:message code="select"/>>
<select name="ipCfg[${otherTable.tableName}].direction" class="selectpicker show-tick form-control required" title=<spring:message code="select"/>>
<option value="" ><spring:message code="select"/></option>
<option value="0" <c:if test="${_cfg.ipCfg[otherTable.tableName].direction==0}">selected</c:if>>0</option>
<option value="1" <c:if test="${_cfg.ipCfg[otherTable.tableName].direction==1}">selected</c:if>>1</option>
@@ -294,7 +294,7 @@
<div class="col-md-6">
<c:choose>
<c:when test="${mainTableType eq '1' and otherTable==null}">
<select name="ipCfg[${mainTable}].protocol" class="selectpicker show-tick form-control" title=<spring:message code="select"/>>
<select name="ipCfg[${mainTable}].protocol" class="selectpicker show-tick form-control" required title=<spring:message code="select"/>>
<option value=""><spring:message code="select"/></option>
<option value="6" <c:if test="${_cfg.ipCfg[mainTable].protocol==6}">selected</c:if>>TCP</option>
<option value="17" <c:if test="${_cfg.ipCfg[mainTable].protocol==17}">selected</c:if>>UDP</option>
@@ -302,7 +302,7 @@
</select>
</c:when>
<c:when test="${otherTable!=null and otherTable.tableType eq '1'}">
<select name="ipCfg[${otherTable.tableName}].protocol" class="selectpicker show-tick form-control" title=<spring:message code="select"/>>
<select name="ipCfg[${otherTable.tableName}].protocol" class="selectpicker show-tick form-control required" title=<spring:message code="select"/>>
<option value="" ><spring:message code="select"/></option>
<option value="6" <c:if test="${_cfg.ipCfg[otherTable.tableName].protocol==6}">selected</c:if>>TCP</option>
<option value="17" <c:if test="${_cfg.ipCfg[otherTable.tableName].protocol==17}">selected</c:if>>UDP</option>

View File

@@ -182,8 +182,7 @@ $(function(){
checkIp = /\S+/;
}
return this.optional(element) || (checkIp.test(value) && (RegExp.$1 < 256 && RegExp.$2 < 256 && RegExp.$3 < 256 && RegExp.$4 < 256));
},
"请输入正确的IP!"
}
);
});
</script>

View File

@@ -40,6 +40,19 @@ $(function(){
errorContainer: "#messageBox"
});
$.validator.addMethod(
"checkIp",
function(value, element, params) {
var checkIp;
if ($("[name$=ipType]").val() == 4) {
checkIp = /((25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))/;
} else {
checkIp = /\S+/;
}
return this.optional(element) || (checkIp.test(value) && (RegExp.$1 < 256 && RegExp.$2 < 256 && RegExp.$3 < 256 && RegExp.$4 < 256));
}
);
$("#ipSelect").change(function(){
if($(this).prop("checked")){
$("[name^='ipCfg']").removeProp("disabled");
@@ -56,6 +69,23 @@ $(function(){
$("[name^='ipCfg']").attr("disabled",true);
}
});
function myValidate(flag) {
if (flag) {
myValidate(false);
$("[name=ipCfg\\[http_ip_cfg\\]\\.srcIp]").each(function(){
$(this).rules("add", {
checkIp: true,
messages: {
required:'<spring:message code="required"/>'
}
});
});
} else {
}
}
$(".district").on("change",function(){
var text=$(this).find("option:selected").text().toLowerCase();
var other=$(this).parent("div").siblings(".otherValue");

View File

@@ -20,6 +20,7 @@
rangelength: $.validator.format("Please enter a value between {0} and {1} characters long."),
range: $.validator.format("Please enter a value between {0} and {1}."),
max: $.validator.format("Please enter a value less than or equal to {0}."),
min: $.validator.format("Please enter a value greater than or equal to {0}.")
min: $.validator.format("Please enter a value greater than or equal to {0}."),
checkIp: $.validator.format("Please enter a correct IP address.")
});
}(jQuery));

View File

@@ -20,6 +20,7 @@
rangelength: $.validator.format("Пожалуйста, введите значение длиной от {0} до {1} символов."),
range: $.validator.format("Пожалуйста, введите число от {0} до {1}."),
max: $.validator.format("Пожалуйста, введите число, меньшее или равное {0}."),
min: $.validator.format("Пожалуйста, введите число, большее или равное {0}.")
min: $.validator.format("Пожалуйста, введите число, большее или равное {0}."),
min: $.validator.format(" Пожалуйста, введите  правильный  IP - адрес.")
});
}(jQuery));

View File

@@ -20,6 +20,7 @@
rangelength: $.validator.format("请输入一个长度介于 {0} 和 {1} 之间的字符串"),
range: $.validator.format("请输入一个介于 {0} 和 {1} 之间的值"),
max: $.validator.format("请输入一个最大为 {0} 的值"),
min: $.validator.format("请输入一个最小为 {0} 的值")
min: $.validator.format("请输入一个最小为 {0} 的值"),
checkIp: $.validator.format("请输入一个合法的IP")
});
}(jQuery));