facebook

How to set up a new @RequestMapping

  1. MyEclipse IDE
  2.  > 
  3. Spring Development
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #311156 Reply

    Greg Soulsby
    Member

    Have generated my first app and am adding my first function. The button to trigger the new function is working and it points to /appname/newfunction.

    So I copied one of the @RequestMapping sections from within a controler, leaving the code the same except for changing the name and the @RequestMapping to /appname/newfunction. Closed MyEclipse and re-started.

    But when I click the button I get “http status 404 the requested resource is not available.”

    Can you explain to a newbee what the process is for a new @RequestMapping?

    Thanks

    Greg

    #311171 Reply

    davemeurer
    Member

    Hello Greg,

    It sounds like you have the Controller setup correctly. The other piece that needs to be configured is the web.xml.

    In the WEB-INF/web.xml of a ME4S scaffolded MVC application, you’ll notice several servlet-mapping entries that match the Controller Request Mapping URLs. The reason these are all referenced in the web.xml is so the web service knows to direct the request to the Servlet. Otherwise, the server thinks someone is browsing to a directory.

    You can also use wildcards in the servlet-mappings. For instance, you’ll find a *.action servlet-mapping. This states that any URL ending with “.action” will go through the Servlet. So, if you renamed your RequestMapping URL to /appname/newfunction.action, it should work without any modification to the web.xml. Or just add /appname/newfunction as a new servlet mapping and you should be all set.

    Let me know if this helps.
    Kind regards,
    =Dave

    #311172 Reply

    Greg Soulsby
    Member

    That’s great, not only fixed it but built a little my understanding of how Spring hangs together, which I see is a big job.

    Thanks

    PS any way you could help me with this problem? https://www.genuitec.com/forums/topic/failure-to-test/ – had no response so far

    #311173 Reply

    davemeurer
    Member

    Sounds great, Greg. I’m glad it helped.

    re: PS – sorry, I can’t help with that one… but I will ask around and see if someone can take a look.

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: How to set up a new @RequestMapping

You must be logged in to post in the forum log in