我在阅读有关 spring mvc 的教程时遇到问题。该项目的 jsp 页面如下:
<html>
<head>
<title>Spring 3.0 MVC Series: Hello World - ViralPatel.net</title>
</head>
<body>
hello!
${inf}
</body>
</html>
当我在控制器中为 inf 设置一个值时,“${inf}”无法恢复该值。
我现在该怎么办?
谢谢
添加:控制器的代码:
package net.viralpatel.spring3.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.portlet.ModelAndView;
@Controller
public class HelloWorldController {
@RequestMapping("hello")
public ModelAndView helloWorld() {
String message = "Hello World, Spring 3.0!";
System.out.println(message);
ModelAndView modelandview=new ModelAndView("hello");
modelandview.addObject("inf", message);
//return new ModelAndView("hello", "message", message);
return modelandview;
}
}