Results 1 to 9 of 9

Thread: How to use Annotations for the multiple url mapping

  1. #1
    Join Date
    Dec 2010
    Posts
    15

    Default How to use Annotations for the multiple url mapping

    In our project use struts1.2 integrated to springs2.0 using delegationActionProxy. Now we try to use annotations instead of xml. When i annotate the action class using @component("/url") it does work. when multiple bean is mapped to the same action class i am not able to annotate. I switched to springs 2.5 and tried @controller @RequestMapping({"/url1","url2"}).. Is there any other way to do it?

  2. #2
    Join Date
    Oct 2009
    Location
    Chennai,India
    Posts
    90

    Default

    Code:
    @RequestMapping(value={"/url1", "/url2", "url13"})


    Also

    RequestMapping annotation supports wildcards and ant-style paths
    Code:
    @RequestMapping("/url/**")
    Rgds
    Vedamoorthi Vairam

  3. #3
    Join Date
    Dec 2010
    Posts
    15

    Default

    I have tried the solution u gave it is not working.. It is giving the error "No bean defined"

    ex:

    <action path="/removeSurveyFromAdminInbox" scope="session" type="org.springframework.web.struts.DelegatingAct ionProxy" name="surveyForm">
    <forward name="admininbox" path="/showAdminInbox.do" />
    </action>

    <action path="/removeSurveyFromInbox" scope="session" type="org.springframework.web.struts.DelegatingAct ionProxy" name="surveyForm">
    <forward name="inbox" path="/showInbox.do" />
    </action>

    both the bean has to call the same action class..

    @Controller
    @RequestMapping(value={"/removeSurveyFromInbox","/removeSurveyFromAdminInbox"})
    public class RemoveSurveyAction extends ApplicationAction{
    // do
    }

    Any help would be appreciated?
    Last edited by paranidharan; Dec 17th, 2010 at 09:00 AM.

  4. #4
    Join Date
    Oct 2009
    Location
    Chennai,India
    Posts
    90

    Default

    Please copy your log here;It would helpful to find the case
    use [code] [/ code] while post the log trace
    Rgds
    Vedamoorthi Vairam

  5. #5
    Join Date
    Dec 2010
    Posts
    15

    Default

    [12/17/10 20:43:09:171 IST] 0000002a SystemErr R org.springframework.beans.factory.NoSuchBeanDefini tionException: No bean named '/removeSurveyFromAdminInbox' is defined
    [12/17/10 20:43:09:171 IST] 0000002a SystemErr R at org.springframework.beans.factory.support.DefaultL istableBeanFactory.getBeanDefinition(DefaultListab leBeanFactory.java:391)
    [12/17/10 20:43:09:171 IST] 0000002a SystemErr R at org.springframework.beans.factory.support.Abstract BeanFactory.getMergedLocalBeanDefinition(AbstractB eanFactory.java:999)
    [12/17/10 20:43:09:171 IST] 0000002a SystemErr R at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:233)
    [12/17/10 20:43:09:171 IST] 0000002a SystemErr R at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:174)
    [12/17/10 20:43:09:171 IST] 0000002a SystemErr R at org.springframework.context.support.AbstractApplic ationContext.getBean(AbstractApplicationContext.ja va:887)
    [12/17/10 20:43:09:171 IST] 0000002a SystemErr R at org.springframework.web.struts.DelegatingActionPro xy.getDelegateAction(DelegatingActionProxy.java:12 7)
    [12/17/10 20:43:09:171 IST] 0000002a SystemErr R at org.springframework.web.struts.DelegatingActionPro xy.execute(DelegatingActionProxy.java:109)
    [12/17/10 20:43:09:171 IST] 0000002a SystemErr R at org.apache.struts.action.RequestProcessor.processA ctionPerform(RequestProcessor.java:431)
    [12/17/10 20:43:09:171 IST] 0000002a SystemErr R at org.apache.struts.action.RequestProcessor.process( RequestProcessor.java:236)
    [12/17/10 20:43:09:171 IST] 0000002a SystemErr R at org.apache.struts.action.ActionServlet.process(Act ionServlet.java:1196)
    [12/17/10 20:43:09:171 IST] 0000002a SystemErr R at org.apache.struts.action.ActionServlet.doPost(Acti onServlet.java:432)
    [12/17/10 20:43:09:171 IST] 0000002a SystemErr R at javax.servlet.http.HttpServlet.service(HttpServlet .java:763)
    [12/17/10 20:43:09:171 IST] 0000002a SystemErr R at javax.servlet.http.HttpServlet.service(HttpServlet .java:856)
    [12/17/10 20:43:09:171 IST] 0000002a SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapper.ser vice(ServletWrapper.java:966)
    [12/17/10 20:43:09:171 IST] 0000002a SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapper.ser vice(ServletWrapper.java:907)
    [12/17/10 20:43:09:171 IST] 0000002a SystemErr R at com.ibm.ws.webcontainer.filter.WebAppFilterChain.d oFilter(WebAppFilterChain.java:145)
    [12/17/10 20:43:09:171 IST] 0000002a SystemErr R at com.statestr.basel2.framework.web.common.ThreadTra nsactionFilter.doFilter(ThreadTransactionFilter.ja va:83)
    [12/17/10 20:43:09:171 IST] 0000002a SystemErr R at org.springframework.web.filter.DelegatingFilterPro xy.invokeDelegate(DelegatingFilterProxy.java:183)
    [12/17/10 20:43:09:171 IST] 0000002a SystemErr R at org.springframework.web.filter.DelegatingFilterPro xy.doFilter(DelegatingFilterProxy.java:138)
    [12/17/10 20:43:09:171 IST] 0000002a SystemErr R at com.ibm.ws.webcontainer.filter.FilterInstanceWrapp er.doFilter(FilterInstanceWrapper.java:190)
    [12/17/10 20:43:09:171 IST] 0000002a SystemErr R at com.ibm.ws.webcontainer.filter.WebAppFilterChain.d oFilter(WebAppFilterChain.java:130)
    [12/17/10 20:43:09:171 IST] 0000002a SystemErr R at com.ibm.ws.webcontainer.filter.WebAppFilterChain._ doFilter(WebAppFilterChain.java:87)
    [12/17/10 20:43:09:171 IST] 0000002a SystemErr R at com.ibm.ws.webcontainer.filter.WebAppFilterManager .doFilter(WebAppFilterManager.java:701)
    [12/17/10 20:43:09:171 IST] 0000002a SystemErr R at com.ibm.ws.webcontainer.filter.WebAppFilterManager .doFilter(WebAppFilterManager.java:646)
    [12/17/10 20:43:09:171 IST] 0000002a SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapper.han dleRequest(ServletWrapper.java:475)
    [12/17/10 20:43:09:171 IST] 0000002a SystemErr R at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.h andleRequest(ServletWrapper.java:463)
    [12/17/10 20:43:09:171 IST] 0000002a SystemErr R at com.ibm.ws.webcontainer.webapp.WebApp.handleReques t(WebApp.java:3129)
    [12/17/10 20:43:09:171 IST] 0000002a SystemErr R at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequ est(WebGroup.java:238)
    [12/17/10 20:43:09:171 IST] 0000002a SystemErr R at com.ibm.ws.webcontainer.WebContainer.handleRequest (WebContainer.java:811)
    [12/17/10 20:43:09:171 IST] 0000002a SystemErr R at com.ibm.ws.wswebcontainer.WebContainer.handleReque st(WebContainer.java:1433)
    [12/17/10 20:43:09:171 IST] 0000002a SystemErr R at com.ibm.ws.webcontainer.channel.WCChannelLink.read y(WCChannelLink.java:93)
    [12/17/10 20:43:09:171 IST] 0000002a SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLi nk.handleDiscrimination(HttpInboundLink.java:465)
    [12/17/10 20:43:09:171 IST] 0000002a SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLi nk.handleNewInformation(HttpInboundLink.java:394)
    [12/17/10 20:43:09:171 IST] 0000002a SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCa llback.complete(HttpICLReadCallback.java:102)
    [12/17/10 20:43:09:171 IST] 0000002a SystemErr R at com.ibm.ws.tcp.channel.impl.AioReadCompletionListe ner.futureCompleted(AioReadCompletionListener.java :152)
    [12/17/10 20:43:09:171 IST] 0000002a SystemErr R at com.ibm.io.async.AbstractAsyncFuture.invokeCallbac k(AbstractAsyncFuture.java:213)
    [12/17/10 20:43:09:171 IST] 0000002a SystemErr R at com.ibm.io.async.AbstractAsyncFuture.fireCompletio nActions(AbstractAsyncFuture.java:195)
    [12/17/10 20:43:09:171 IST] 0000002a SystemErr R at com.ibm.io.async.AsyncFuture.completed(AsyncFuture .java:136)
    [12/17/10 20:43:09:171 IST] 0000002a SystemErr R at com.ibm.io.async.ResultHandler.complete(ResultHand ler.java:194)
    [12/17/10 20:43:09:171 IST] 0000002a SystemErr R at com.ibm.io.async.ResultHandler.runEventProcessingL oop(ResultHandler.java:741)
    [12/17/10 20:43:09:187 IST] 0000002a SystemErr R at com.ibm.io.async.ResultHandler$2.run(ResultHandler .java:863)
    [12/17/10 20:43:09:187 IST] 0000002a SystemErr R at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.j ava:1510)

  6. #6
    Join Date
    Dec 2010
    Posts
    15

    Default @controller

    @controller
    @RequestMapping({"/url"} is not working for struts-springs integration. Can anyone suggest a new mapping pattern

  7. #7
    Join Date
    Jul 2010
    Location
    Venice, Italy
    Posts
    710

    Default

    If you are using Struts for MVC you shouldn't be using Spring Web MVC and so no controllers and request mappings but struts action config instead. You choose one thing or the other, since they both do the same job. Spring core integrates very well with Struts, but you can't have 2 MVC frameworks working at the same time.

    So, either abandon Struts in favor of Spring's annotated web mvc (which I recommend doing if you can) OR use Struts on top of Spring core but DON'T use Spring web mvc (i.e. no dispatcherservlet). Read the reference guide about Spring - Struts integration.

  8. #8
    Join Date
    Dec 2010
    Posts
    15

    Default

    I am using struts-config and delegating the action management to springs. We would like to avoid context files by means of annotations. When doing so i confront a issue of not able to map the multiple url mapped to the same class. We are using sturts mvc and not spring mvc.

  9. #9
    Join Date
    Jul 2010
    Location
    Venice, Italy
    Posts
    710

    Default

    From your second post:

    @Controller
    @RequestMapping
    this is very like Spring Web Mvc to me...unless Struts has evolved from actions to annotated controllers...

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •