简体   繁体   中英

Spring MVC rendering 404 due to wrong view

I'm debugging a controller method in Spring MVC that should return a view, but I'm getting a 404 page.

Error

HTTP Status 404 
/WEB-INF/views/responsive/pages/company/myCompanyCreatePurchaseOrderPage.jsp

The view is actually located in

/WEB-INF/views/pages/company/myCompanyCreatePurchaseOrderPage.jsp

Code

@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";
}

Where does this prefix get set?

InternalResourceViewResolver bean on your web.xml or applicationContext.xml

Sample

<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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM