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 从控制器到查看页面的数据传输_Spring Mvc - Fatal编程技术网

Spring mvc 从控制器到查看页面的数据传输

Spring mvc 从控制器到查看页面的数据传输,spring-mvc,Spring Mvc,当我在ModelMap中设置“message”属性时,它不会显示在JSP中。浏览器中显示的不是“message”的值,而是字符串literal${message} UserHandler.java hello.jsp spring-bean-config.xml web.xml 结果页面:这里我希望看到的是welcome,而不是${message} 您的问题不在控制器中,而是在您的视图中hello.jsp。正在发生的是视图将${message}解释为文本,而不是属性的值 我从未使用过js

当我在
ModelMap
中设置“message”属性时,它不会显示在JSP中。
浏览器中显示的不是“message”的值,而是字符串literal
${message}

UserHandler.java

hello.jsp

spring-bean-config.xml

web.xml

结果页面:这里我希望看到的是
welcome
,而不是
${message}

您的问题不在控制器中,而是在您的视图中
hello.jsp
。正在发生的是视图将
${message}
解释为文本,而不是属性的值

我从未使用过jsp,但下面的内容可能会帮您解决这个问题。 在
hello.jsp
中,将行:
${message}
更改为:

user1442922

您是否在web.xml和spring-bean-config.xml的顶部有根声明,为了简洁起见,您是否将它们保留在文章中?如果您的.xml中没有它们,请尝试添加它们,web.xml中的一个应该类似于:

<web-app
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">


你能问清楚你的问题是什么吗?查看页面hello.jsp没有显示消息的值。我的控制器有什么问题吗?它仍然在jsp页面上显示文本${message}。请尝试