jsp 为什么不能接收spring mvc 模型对象?
<servlet><servlet-name>itzcn</servlet-name><servlet-class>org.springframework.web.ser...
<servlet>
<servlet-name>itzcn</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet>
<servlet-mapping>
<servlet-name>itzcn</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping> </web-app>
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean name="/index.do" class="web.IndexController">
<property name="sayHello" value="窗内网欢迎您的到来!"/>
</bean> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix"><!-- 前缀 -->
<value>/</value>
</property>
<property name="suffix"><!-- 后缀 -->
<value>.jsp</value>
</property>
</bean>
</beans>
麻烦高手看一下,是哪里出了问题,index.jsp可以打开,也没错误提示,正常运行,就是jsp不能读出hello的值:${hello},这一句没结果? 展开
<servlet-name>itzcn</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet>
<servlet-mapping>
<servlet-name>itzcn</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping> </web-app>
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean name="/index.do" class="web.IndexController">
<property name="sayHello" value="窗内网欢迎您的到来!"/>
</bean> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix"><!-- 前缀 -->
<value>/</value>
</property>
<property name="suffix"><!-- 后缀 -->
<value>.jsp</value>
</property>
</bean>
</beans>
麻烦高手看一下,是哪里出了问题,index.jsp可以打开,也没错误提示,正常运行,就是jsp不能读出hello的值:${hello},这一句没结果? 展开
展开全部
spring mvc 模型对象? 你说的是ModelAndView吗? 还是说Model; 这个需要调用相应的View Resolver才行。
追问
${hello}
public class IndexController implements Controller{
private String sayHello;略
public ModelAndView handleRequest(HttpServletRequest arg0, HttpServletResponse arg1) throws Exception {return new ModelAndView("index","hello",sayHello);
}}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询