0

I'm trying to redirect to a different page. I've tried this locally on my machine using jetty and the redirect works correctly. Now if I deploy the war file to tomcat and try to redirect the page I get this error.

HTTP Status 500 - File "/WEB-INF/jsp/.jsp" not found
javax.servlet.ServletException: File "/WEB-INF/jsp/.jsp" not found
org.apache.jasper.servlet.JspServlet.handleMissingResource(JspServlet.java:412)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:379)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:229)
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1047)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:817)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:585)
javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)

I'm not sure why its not putting the file name in "WEB-INF/jsp/.jsp".

Here is the java code that sends the redirect.

@RequestMapping(value="/surescriptstart", method=RequestMethod.POST)
public ModelAndView surescriptTes2t(SureScripts pro,HttpServletResponse response , HttpServletRequest request) throws IOException, ServletException{
if(verifySureScripts){
     ....
 Message = "You are done!";
 response.sendRedirect("done.html");
 }else{     
 response.sendRedirect("surescriptstart.html");
 }
     ....

Here is part of the servlet.xml

<bean id="viewResolver"
    class="org.springframework.web.servlet.view.UrlBasedViewResolver">
    <property name="viewClass"
        value="org.springframework.web.servlet.view.JstlView" />
    <property name="prefix" value="/WEB-INF/jsp/" />
    <property name="suffix" value=".jsp" />
</bean>
4

1 回答 1

3

你从surescriptTes2t方法返回什么?您必须返回一个空视图名称,因此 spring mvc 尝试使用/WEB-INF/jsp/.jsp处的 jsp 解决它,而不是发送 302 重定向。

如果您只需要重定向,请尝试使其无效

public void surescriptTes2t
于 2013-08-13T01:27:05.210 回答