【发布时间】:2015-02-13 18:36:19
【问题描述】:
我是 Java Spring MVC 的新手。按照网上的一些教程,我不知道为什么,但是当我将一些文本从controller 传递给view 时,文本似乎没有出现。
Controller
@Controller
public class HelloWorldController {
@RequestMapping(value = "/helloWorld.htm", method = RequestMethod.GET)
public ModelAndView helloWorld(){
String message = "Hello Spring MVC!";
return new ModelAndView("helloWorld", "message", message);
}
}
View
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
Message is: ${message}
</body>
</html>
我关注的所有教程都有这个确切的代码,但它不起作用。我在这里想念什么?
【问题讨论】:
-
我已经有一段时间没有做 JSP 了,但我很确定这不是您在 JSP 中声明字符串的方式。
Message is: ${message}被解释为文字文本,不是吗? -
根本不解释,看不到文字。
标签: java spring spring-mvc jakarta-ee