Announcement Announcement Module
Collapse
No announcement yet.
Simple Form Controller and annotations Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Simple Form Controller and annotations

    Hello,

    I had used Spring 2.5 to create a SImpleFormController and it worked fine. I used the same java class for multiple urls. Since form submission processing was more or less similar, I absolutely loved it, less testing, fewer errors.

    I defined them in web-layer.xml as follows

    Code:
    <bean name="/ind_address_edit.htm" id="EditController3" class ="com.netmemex.netmx.web.AddressFullEditController" autowire="byType" scope="session">
    		<property name ="masterService" ref="individualService"/>
    		<property name ="menuItem" ref ="indMag"/>
    		<property name="indOrg" ref="I"/>
                    <property name="viewName" value="indAddressFullEdit"/>
    	</bean>
    	
    	<bean name="/org_address_edit.htm" id="EditController4" class ="com.netmemex.netmx.web.AddressFullEditController" autowire="byType" scope="session">
    		<property name ="masterService" ref="organizationService"/>
    		<property name ="menuItem" ref ="orgMag"/>
    		<property name="indOrg" ref="O"/>
                    <property name="viewName" value="orgAddressFullEdit"/>
    	</bean>
    but now when i have to upgrade to spring 3, i do not see any documentation to do this.

    Is there any way to make this happen using annotations. can i use two different paths in @RequestMapping??? If not, then any ideas on how I can accomplish this???


    Thanks,

    ~s.

  • #2
    bump !!!

    Comment


    • #3
      You could map URL requests to different methods inside the same controller using the @RequestMapping annotation http://static.springsource.org/sprin...stMapping.html. Will this work for you?

      Comment


      • #4
        that does not work because one method can be annotated only once with @RequestMapping

        I wish to map multiple url paths to the same function

        Code:
        @RequestMapping(value="/ind_address_edit.htm" method = RequestMethod.GET)
        @RequestMapping(value="/org_address_edit.htm" method = RequestMethod.GET)
        public String setupForm(HttpServletRequest request, Model model) 
        {...}
        is not supported AFAIK

        Thanks

        s.

        Comment


        • #5
          You may have figured this out by now but you can provide multiple values for the @RequestMapping annotations "value" attribute:

          @RequestMapping(value = {"/ind_address_edit.htm", "/org_address_edit.htm"} ... )

          Comment

          Working...
          X