zoukankan      html  css  js  c++  java
  • EL表达式无法显示Model中的数据

    后台程序通过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">

    加上即可~~~~

  • 相关阅读:
    画了朵花
    定位
    浮动
    盒模型
    html+css笔记1
    闭包
    高阶函数
    函数
    Map Set iterable
    git stash clear/drop 后代码如何恢复
  • 原文地址:https://www.cnblogs.com/tongxuping/p/7343888.html
Copyright © 2011-2022 走看看