SpringMVC两个控制器类,注解都相同,但是一个需要设置request.setAttribute才能在jsp中el表达式里取到值。比如${anti.id}必须设置request.setAttribute才可以取到id值。@RequestMapping("/anti_list/{pageNo}")public String list(HttpServletRequest request, AntiForgery anti, @PathVariable Integer pageNo) { request.setAttribute("anti", anti); // 只多了这一句不同 logger.debug("anti_list"); return "/msg/antiforgery_list";} 但是另一个没有设置request.setAttribute,但是也能在jsp中的el表达式里取到值。比如${article.id}可以直接取到值。但并没有设置request.setAttribute。@RequestMapping("/anti_list/{pageNo}")public String list(HttpServletRequest request, Article article, @PathVariable Integer pageNo) { logger.debug("article_list"); return "/msg/article_list";} 两个方法分别在不同控制器类中,但是取值一个需要request.setAttribute设置,另一个不需要。这是为什么呢?
添加回答
举报
0/150
提交
取消