Why can't I get this to work in my Controller
@RequestMapping(method = RequestMethod.POST) public String onSubmit(     Model model,     @ModelAttribute("form") Form form,     BindingResult result, HttpServletRequest request)     throws IOException, WriteException, BiffException {      if (result.hasErrors()) {         return "redirect:index.html";     }   }   I get:
javax.servlet.ServletException: Could not resolve view with name 'redirect:index.html' in servlet with name 'dispatcher'
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1042)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:798)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
I've got this to work before. Why not now?
Try this, it should work if you have configured your view resolver properly
 return "redirect:/index.html"; 
                        Also note that redirect: and forward: prefixes are handled by UrlBasedViewResolver, so you need to have at least one subclass of UrlBasedViewResolver among your view resolvers, such as InternalResourceViewResolver.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With