我正在开发一个简单的 spring mvc web 应用程序:一个简单的控制器:
public class LoginController extends MultiActionController {
private final static String VIEW_LOGIN = "/login";
public ModelAndView handleLogin(HttpServletRequest request,
HttpServletResponse response){
ModelAndView mv = new ModelAndView(VIEW_LOGIN);
String prova = "PROVA123";
mv.addObject(prova);
return mv;
}
}
一个简单的jsp页面:
<%@ taglib uri='http://java.sun.com/jsp/jstl/core' prefix='c'%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Login - Gestione Studenti</title>
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<p><c:out value="${prova}"/></p><br>
</body>
</html>
这是调度程序 servlet xml 文件
<bean id="loginController" class="it.mediosoft.gestionestudenti.web.LoginController">
<property name="methodNameResolver" ref="handlerResolver"/>
</bean>
<bean id="urlMapping"
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="/login.html">loginController</prop>
</props>
</property>
</bean>
<bean id="handlerResolver"
class="org.springframework.web.servlet.mvc.multiaction.PropertiesMethodNameResolver">
<property name="mappings">
<props>
<prop key="/login.html">handleLogin</prop>
</props>
</property>
</bean>
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass"><value>org.springframework.web.servlet.view.JstlView</value></property>
<property name="prefix"><value>/WEB-INF/jsp/</value></property>
<property name="suffix"><value>.jsp</value></property>
</bean>
为什么在 login.jsp 中我不能使用 loginController 在 ModelAndView 返回的对象?"c:out" 不打印任何东西....有什么建议吗?