Solved

Submit using a link spring MVC-3

Posted on 2010-09-19
7
2,470 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
Comment Utility

>>> 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
Comment Utility
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
Comment Utility
Have change for all ??
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

by:lotrzz
Comment Utility
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 100 total points
Comment Utility
As per ur code ="/edit",
but ur not using that?
0
 

Author Comment

by:lotrzz
Comment Utility
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
Comment Utility
yes, the url was not matching
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

763 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now