I have a question on redirect page one folder into another folder of jsp pages. I defined viewResolver
:
<bean id="viewResolver" 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>
But My folder struture is
WEB-ROOT
|__JSP
|__user
|_userdashboardpage.jsp
|__loginpage.jsp
|__web.xml
Iam trying to validate the user details e.g. username, password when the logged the user page using validator interface. But if any error occurs while entered the blank details then occured errors and redirect the same page i.e, loginpage
using getFormView
method with prefix
property in viewResolver
bean.
But errors is not displaying in the same page. The container looking /jsp/loginpage
. But my page having outside jsp
folder. If iam removing the prefix then it shows errors.
So how to redirect the page one folder jsp into another folder jsp or web-root into jsp>user>userdashboard.jsp
. How to dispay the error in this scenario. Can i go to chain view resolvers?
The
prefix
property of yourInternalResourceViewResolver
shouldn't go any deeper than the top of your JSP hierarchy. Since not all of your JSPs are under/jsp
, you can't use that as your prefix.So remove the
prefix
property, and use the appropriate view names. So to usejsp/user/userdashboardpage.jsp
, you should return the view namejsp/user/userdashboardpage
from your controller. To useloginpage.jsp
, return justloginpage
.No. Multiple
InternalResourceViewResolver
cannot be chained, due to the way the servlet API works.