java//jsp 去掉首尾空格
java:
String value = val.trim();
js:
var remarks = $("#remarks").val().replace(/(^s*)|(s*$)/g,"");
举例:
js:
function doSubModify(){
var modify_adjBrokerLevel = $("#modify_adjBrokerLevel").val();
var remarks = $("#remarks").val().replace(/(^s*)|(s*$)/g,"");
if(modify_adjBrokerLevel != '' && remarks.length>0){
layer.confirm('是否确认调整记录', {
btn: ['确定','取消'] //按钮
},function(){
var map = {};
map["id"] = $("#modify_id").val();
map["adjBrokerLevel"] = modify_adjBrokerLevel;
map["remarks"] = remarks;
$.ajax({
url : "${ctx}/assessment/doSubModify.in",
type : 'POST',
dataType : 'json',
contentType : "application/json",
data : JSON.stringify(map),
success : function(response) {
layer.msg('调整成功!');
//$("#modal-detail").modal("hidden");
$("#modal-detail").hedden;
location.reload();
/* table.ajax.reload(); */
}
});
});
}else{
layer.msg('必填信息不能为空!');
}
}
java:
controller:
@ResponseBody
@RequestMapping(value = "doSubModify.in")
public String doSubModify(@RequestBody Map map, HttpServletRequest request) {
String id = map.get("id");
String adjBrokerLevel = map.get("adjBrokerLevel").trim();
String remarks = map.get("remarks");
TblAssessBroker ass = assessmentSurface.modifyById(id, adjBrokerLevel, remarks);
logger.debug("考核数据修改提交");
return JSON.toJSONString(ass);
}