thymeleaf
判断对象是否为空有关逻辑处理
场景一
在项目中,有时会遇到下面场景:
添加页面和编辑页面共用一个页面,而通过后台传来的对象来判断提示用户是编辑页面还是添加页面,而编辑页面要使用这个对象的,添加页面用不到。在此记录下自己遇到的问题,看到了别人的博客才解决了
@RequestMapping(path = {
"/add", "edit"}, method = {
RequestMethod.GET})
public String addOrEdit(Model model, @RequestParam(name = "postId", required = false) Long postId) {
if (!StringUtils.isEmpty(postId)) {
UserLoginResult userLoginResult = (UserLoginResult) SecurityUtil