Announcement Announcement Module
Collapse
No announcement yet.
successview for SimpleFormController Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • successview for SimpleFormController

    Hi All,

    When specifying your form based on SimpleFormController in the XML config. file, does the JSP used for successview have to be "public", I'd like to have it hidden from public view in my WEB-INF/jsp directory.

    Here's what I have so far:

    <bean id="updateAccountFormController" class="com.xxx.controller.UpdateAccountFormControl ler">
    <property name="sessionForm" value="true"/>
    <property name="commandName" value="updateAccountCommand"/>
    <property name="commandClass" value="com.thresholdcorp.hsmgmt.orm.Customer"/>
    <property name="validator">
    <bean class="com.thresholdcorp.thresholdusers.validator. UpdateAccountValidator"/>
    </property>
    <property name="formView" value="updateaccount"/>
    <property name="successView" value="updateaccountok.jsp"/>
    <property name="dao">
    <ref bean="customerDao"/>
    </property>
    </bean>

  • #2
    Spring recommends that you should not keep your jsp's public.You should keep them always in WEB-INF directory.You can use the InternalSourceViewResolver provided by spring to hide your jsps.
    You can use the following code in your bean definitions file:
    <bean id="viewResolver"
    class="org.springframework.web.servlet.view.Intern alResourceViewResolver">
    <property name="viewClass">
    <value>org.springframework.web.servlet.view.JstlVi ew
    </value>
    </property>
    <property name="prefix">
    <value>/WEB-INF/jsp/</value>
    </property>
    <property name="suffix">
    <value>.jsp</value>
    </property>
    </bean>
    and you need to change your success view value as "updateaccountok"
    I hope this solves your query.
    Cheers,
    Sushant

    Comment


    • #3
      Tried your suggestion, got an error

      Thanks for the response, I can see that it should've worked but after applying the form I now get an error as though it can't find the success view JSP. My config. settings are below:

      HTTP Status 404 - /user/updateaccountok

      type Status report

      message /user/updateaccountok

      description The requested resource (/user/updateaccountok) is not available.
      Apache Tomcat/5.5.27

      ----------------------------------------------------------------------
      <bean id="updateAccountFormController" class="com.thresholdcorp.thresholdusers.controller .UpdateAccountFormController">
      <property name="sessionForm" value="true"/>
      <property name="commandName" value="updateAccountCommand"/>
      <property name="commandClass" value="com.thresholdcorp.hsmgmt.orm.Customer"/>
      <property name="validator">
      <bean class="com.thresholdcorp.thresholdusers.validator. UpdateAccountValidator"/>
      </property>
      <property name="formView" value="updateaccount"/>
      <property name="successView" value="updateaccountok"/>
      <property name="dao">
      <ref bean="customerDao"/>
      </property>
      </bean>

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

      Comment

      Working...
      X