我有一个视图解析器:
<bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<property name="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".jsp"/>
<property name="order"><value>1</value></property>
</bean>
一种方法:
@RequestMapping("/hello_world.html")
public ModelAndView index() {
ModelAndView mav = new ModelAndView("test");
return mav;
}
我想渲染/WEB-INF/jsp/test.jsp,但它总是尝试渲染/WEB-INF/jsp/hello_world.jsp
如何在index()中定义custon视图页面?
谢谢
答案 0 :(得分:1)
导入org.springframework.web.servlet.ModelAndView而不是org.springframework.web.portlet.ModelAndView! ; ^)
答案 1 :(得分:0)
@RequestMapping("/hello_world.html")
public ModelAndView index() {
ModelAndView mav = new ModelAndView("/test");
return mav;
}
而不是“测试”,请执行“/ test”