?
Solved

Submit using a link spring MVC-3

Posted on 2010-09-19
7
Medium Priority
?
2,522 Views
Last Modified: 2013-11-11

I am trying to load a form using a  url.  But somehow i am getting this error

org.springframework.web.servlet.PageNotFound - Request method 'GET' not supported

here is the relevant jsp code
<c:forEach items="${ContactSearchResults}"  var="res">
             <c:url var="editUrl" value="/edit.html">  
                     <c:param name="id" value="${res.id}" />               
              </c:url>           
  <tr>
        <td ><a name="edit" href='<c:out value="${editUrl}"/>' onclick="edit2('<c:out value="${res.id}"/>')">${res.firstname}&nbsp;</a></td>
                    <td ><nobr>${res.lastname}</nobr>&nbsp;</td>


here is  controller method - I am not even printing the first system.out which means I am not finding the controller

@RequestMapping(value ="/edit", params="edit",  method = RequestMethod.GET)
      public ModelAndView edit(@RequestParam("id") String recId){
            System.out.println("i m here-555");
                                            Contact con2 = conService.load(recId);
            
            ModelAndView mv = new ModelAndView();
                                           mv.setViewName("contactForm");
            mv.addObject("command", con2);
            return mv;
      }


what am I doing wrong  that I am getting this error
org.springframework.web.servlet.PageNotFound - Request method 'GET' not supported

If I use a submit button instead of a URL, it works fine (below is the submit button code that works)
<td ><input type="submit" name="editc" value="edit" onclick="edit('<c:out value="${res.id}"/>')"/></td>
0
Comment
Question by:lotrzz
  • 4
  • 3
7 Comments
 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 33714176

>>> onclick="edit('<c:out value="${res.id}"/>')"/></td>
This is the pblm onclick satrting with double qutoe inside "${res.id}" your finish so that only its give pblm
onclick="edit('${res.id}')"/>
Try this ........
0
 

Author Comment

by:lotrzz
ID: 33715242
same error
HTTP Status 405 - Request method 'GET' not supported

Somehow it can't able to find the controller method because I am not even hitting the first system.out, something must be wrong in the mapping..........pls help.
0
 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 33715833
Have change for all ??
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:lotrzz
ID: 33727661
I donot understand, can you pls show me an example how to submit to a controller using a link?  I can use c:url or spring:url  or anything, but i need to hit the controller method
0
 
LVL 20

Accepted Solution

by:
Sathish David  Kumar N earned 400 total points
ID: 33728317
As per ur code ="/edit",
but ur not using that?
0
 

Author Comment

by:lotrzz
ID: 33740634
my url is  /edit.do?id=1 and my controller has @Requestparam(value="/edit") is this not correct?  Is there any way I can submit a from using a url  (or c:url  or  spring:url)  I want to use a link not a button.
0
 

Author Closing Comment

by:lotrzz
ID: 33752552
yes, the url was not matching
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
A solution for Fortify Path Manipulation.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month16 days, 11 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question