PDA

View Full Version : Controller successview being intercepted by viewResolver


martynhiemstra
Mar 27th, 2007, 10:50 AM
Hi All.

I have a viewResolver:

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

I have defined a controller:

<bean id="addPersonController" class="com.test.controller.AddPersonController">
<property name="sessionForm"><value>false</value></property>
<property name="commandName"><value>addPersonCommandBean</value></property>
<property name="commandClass"><value>com.test.command.AddPersonCommandBean</value></property>
<property name="validator"><ref bean="addPersonValidator" /></property>
<property name="formView"><value>secure/addPerson</value></property>
<property name="successView"><value>/secure/index.do</value></property>
</bean>

I have mapped my controller to a url /secure/addPerson.do

When I goto the url /secure/addPerson.do I see the jsp file secure/addPerson which is located in /WEB-INF/jsp/secure/addPerson.jsp so the viewResolver works.

When I click on submit I see messages in the log about the validator being called and that no errors occure. Then I get a 404 error:

/WEB-INF/jsp//secure/index.do.jsp is not available.

Somehow, instead of forwarding to the controller and executing onSubmit in my controller, the controller successview is used as rediect url and intercepted by the viewResolver.

Marten Deinum
Mar 27th, 2007, 11:10 AM
The problem is that it isn't used as a redirect URL. The view resolver is trying to resolve a view with the name you gave in succesview. Prefix it with redirect: to make it work as a redirect.