首页 > 其他 > 详细

EL表达式无法显示Model中的数据

时间:2017-08-11 09:15:30      阅读:226      评论:0      收藏:0      [点我收藏+]

后台程序通过Debug都能正常返回数据并封装到Model中。而在前台通过EL表达式取值时却是原样输出,如${cart.num}...

 1 ///展现我的购物车
 2 @RequestMapping("/show")
 3 public String myCart(Model model) throws Exception{
 4     //准备数据
 5     
 6     Long userId = userThreadlocal.getUserId();
 7     List<Cart> cartList = cartService.queryByUserId(userId);
 8     model.addAttribute("cartList", cartList);
 9     
10     return "cart";
11 }

能正常返回数据并通过视图解析器跳转到cart页面,可在cart.jsp中通过EL表达式无法取出。

事故原因:

原来是项目中的web.xml头部声明搞的鬼.....

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    id="jt-manage" version="2.5">

加上即可~~~~

EL表达式无法显示Model中的数据

原文:http://www.cnblogs.com/tongxuping/p/7343888.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!