Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在spring/mvc中,使用;模型";在jsp页面中_Jsp_Spring Mvc_Jstl - Fatal编程技术网

在spring/mvc中,使用;模型";在jsp页面中

在spring/mvc中,使用;模型";在jsp页面中,jsp,spring-mvc,jstl,Jsp,Spring Mvc,Jstl,我在servlet中使用了以下方法: @Override protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { Map<String, Object> myModel = new HashMap<String, Object>(); [...do something

我在servlet中使用了以下方法:

@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {

    Map<String, Object> myModel = new HashMap<String, Object>();

    [...do something...]

    model.put("msg","a message");

    return new ModelAndView("myPage", "model", myModel);

}   
@覆盖
受保护的ModelAndView HandlerRequestInternal(HttpServletRequest请求、HttpServletResponse响应)引发异常{
Map myModel=newhashmap();
[…做点什么…]
model.put(“msg”,“a message”);
返回新模型和视图(“myPage”、“model”、“myModel”);
}   
现在,在myPage.jsp中,我想在${model.msg}上执行if-then-else,并尝试以这种方式使用JSTL:

        <c:choose>
            <c:when test="${!empty model.msg}">
                <p> not empty </p>
            </c:when>
            <c:otherwise>
                <p>empty</p>
            </c:otherwise>
        </c:choose>

不空

空的

但我得到了这样的警告和错误:“测试不支持运行时表达式”

能帮我点忙吗?谢谢

试试这个

        <c:choose>
            <c:when test="${not empty msg}">
                <p> not empty </p>
            </c:when>
            <c:otherwise>
                <p>empty</p>
            </c:otherwise>
        </c:choose>

不空

空的

而且, 如果未导入JSTL 1.1,则必须导入

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>  

请尝试使用最新的maven依赖项

<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>

jstl
jstl
1.2

?我已经看到${!空模型.field}工作。。。这是maven依赖项/标记库导入的区别吗?