我在Spring MVC中调试一个应该返回视图的控制器方法,但是我得到了一个404页面。
错误
HTTP Status 404
/WEB-INF/views/responsive/pages/company/myCompanyCreatePurchaseOrderPage.jsp
视图实际位于
/WEB-INF/views/pages/company/myCompanyCreatePurchaseOrderPage.jsp
代码
@RequestMapping(method = RequestMethod.GET, value = "/admin/getPoNumbers", produces = "application/json")
protected String getPurchaseOrdersFromSettings(@RequestParam(value = "uid")
final String uid, final Model model, final HttpServletRequest request, final RedirectAttributes redirectAttributes) {
// unrelated code omitted
return "pages/company/myCompanyCreatePurchaseOrderPage";
}
此前缀设置在何处?
答案 0 :(得分:1)
web.xml或applicationContext.xml上的InternalResourceViewResolver bean
示例
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass">
<value>org.springframework.web.servlet.view.JstlView</value>
</property>
<property name="prefix">
<value>/jsp/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>