userSelect、empUserSelect的json验证优化

This commit is contained in:
thinkgem
2020-09-24 10:04:27 +08:00
parent 37675bac9d
commit 32f81e1fee
2 changed files with 4 additions and 6 deletions

View File

@@ -25,6 +25,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import com.alibaba.fastjson.JSONValidator;
import com.jeesite.common.codec.EncodeUtils;
import com.jeesite.common.collect.ListUtils;
import com.jeesite.common.collect.MapUtils;
@@ -32,7 +33,6 @@ import com.jeesite.common.config.Global;
import com.jeesite.common.entity.Page;
import com.jeesite.common.lang.DateUtils;
import com.jeesite.common.lang.StringUtils;
import com.jeesite.common.mapper.JsonMapper;
import com.jeesite.common.shiro.realm.AuthorizingRealm;
import com.jeesite.common.utils.excel.ExcelExport;
import com.jeesite.common.utils.excel.annotation.ExcelField.Type;
@@ -424,7 +424,7 @@ public class EmpUserController extends BaseController {
@RequestMapping(value = "empUserSelect")
public String empUserSelect(EmpUser empUser, String selectData, Model model) {
String selectDataJson = EncodeUtils.decodeUrl(selectData);
if (JsonMapper.fromJson(selectDataJson, Map.class) != null){
if (JSONValidator.from(selectDataJson).validate()){
model.addAttribute("selectData", selectDataJson);
}
model.addAttribute("empUser", empUser);

View File

@@ -3,8 +3,6 @@
*/
package com.jeesite.modules.sys.web.user;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -17,12 +15,12 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.alibaba.fastjson.JSONValidator;
import com.jeesite.common.codec.DesUtils;
import com.jeesite.common.codec.EncodeUtils;
import com.jeesite.common.config.Global;
import com.jeesite.common.entity.Page;
import com.jeesite.common.lang.StringUtils;
import com.jeesite.common.mapper.JsonMapper;
import com.jeesite.common.service.ServiceException;
import com.jeesite.common.web.BaseController;
import com.jeesite.modules.sys.entity.User;
@@ -202,7 +200,7 @@ public class UserController extends BaseController {
@RequestMapping(value = "userSelect")
public String userSelect(User user, String selectData, Model model) {
String selectDataJson = EncodeUtils.decodeUrl(selectData);
if (JsonMapper.fromJson(selectDataJson, Map.class) != null){
if (JSONValidator.from(selectDataJson).validate()){
model.addAttribute("selectData", selectDataJson);
}
model.addAttribute("user", user);