Why can\'t I get this to work in my Controller
@RequestMapping(method = RequestMethod.POST)
public String onSubmit(
Model model,
@ModelAttribute(\"fo
Axtavt answer is correct.
This is how your resolver should look like (annotations based):
@Bean
UrlBasedViewResolver resolver(){
UrlBasedViewResolver resolver = new UrlBasedViewResolver();
resolver.setPrefix("/views/");
resolver.setSuffix(".jsp");
resolver.setViewClass(JstlView.class);
return resolver;
}
Obviously the name of your views directory should change based on your project.
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
.
Try this
HttpServletResponse response;
response.sendRedirect(".../webpage.xhtml");
try to change this in your dispatcher-servlet.xml
<!-- Your View Resolver -->
<bean id="viewResolver" class="org.springframework.web.servlet.view.ResourceBundleViewResolver">
<property name="basenames" value="views" />
<property name="order" value="1" />
</bean>
<!-- UrlBasedViewResolver to Handle Redirects & Forward -->
<bean id="urlViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView" />
<property name="order" value="2" />
</bean>
What happens is clearly explained here http://projects.nigelsim.org/wiki/RedirectWithSpringWebMvc
It is possible to define a urlBasedViewResolver
in your properties file:
excel.(class)=fi.utu.seurantaraporttisuodatin.service.Raportti
index.(class)=org.springframework.web.servlet.view.urlBasedView
index.viewClass =org.springframework.web.servlet.view.JstlView
index.prefix = /WEB-INF/jsp/
index.suffix =.jsp
i know this is late , but you should try redirecting to a path and not to a file ha ha