【发布时间】:2012-01-26 10:24:45
【问题描述】:
我的控制器中有以下代码。
@RequestMapping(value = "/sum", method = RequestMethod.GET)
public String sum(@RequestParam("input1") String value1,
@RequestParam("input2") String value2, ModelMap model) {
model.addAttribute(
"msg",
Integer.toString(Integer.parseInt(value1)
+ Integer.parseInt(value2)));
return "index";
}
以下是我的观点:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<body>
<h2>Hello World!</h2>
<h2>Movie Name : <c:out value="${msg}"></c:out></h2>
</body>
</html>
但我的输出是
Hello World!
Movie Name : ${msg}
我哪里错了?
【问题讨论】:
-
我以前见过几个这样的问题,你可以搜索一下。 Here is one、here is another 和 here is another。
-
你知道Spring可以为你做类型转换,你可以将方法参数
Integer,避免手动类型转换吗? -
这个答案:stackoverflow.com/questions/1529184/… 可能会有帮助。
标签: java spring spring-mvc