Reputation:
For all methods I use my standard viewResolver:
<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>
But for a method I want use another viewResolver(empty viewResolver).
How Can I make it for my method ?
@RequestMapping(value="/logOut", method = RequestMethod.GET )
public String logOut(Model model) throws Exception {
model.addAttribute("message", "success logout");
return "home.jsp";//I want forward to webapp/home.jsp
}
Upvotes: 0
Views: 46
Reputation: 124898
Instead of forwarding use a redirect and prefix the returned view with redirect:
@RequestMapping(value="/logOut", method = RequestMethod.GET )
public String logOut(RedirectAttributes redirect) throws Exception {
redirect.addFlashAttribute("message", "success logout");
return "redirect:/home.jsp";//I want forward to webapp/home.jsp
}
Something like that. The redirect/forward prefixes are explained in the reference guide.
Upvotes: 0
Reputation: 328724
Return View
or ModelAndView
instead of String
. Using these types, you can specify the view that you want to use, circumventing the view resolver.
Upvotes: 1