Link to home
Start Free TrialLog in
Avatar of lotrzz
lotrzzFlag for United States of America

asked on

Submit using a link spring MVC-3


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>
Avatar of Sathish David  Kumar N
Sathish David Kumar N
Flag of India image


>>> 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 ........
Avatar of lotrzz

ASKER

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.
Have change for all ??
Avatar of lotrzz

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of Sathish David  Kumar N
Sathish David Kumar N
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lotrzz

ASKER

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.
Avatar of lotrzz

ASKER

yes, the url was not matching