Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Spring framework-Getting error msg upon form submission

Status
Not open for further replies.

varocho

Programmer
Dec 4, 2000
238
0
0
US
I'm working on a Web application developed using the Spring framework, version 3.1.0.

I have a JSP page containing a form which allows the user to select a country from a SELECT dropdown listbox. Submitting the form is supposed to run a database query and return the same JSP page which includes the form as well as an HTML table of author and institute data for the selected country.

Here's part of the code for the JSP page:

Code:
<c:url var="submitUrl" value="/authorsInstitutes.htm"/>
<form:form action="${submitUrl}" method="POST">
   <select id="countryCode">
      <option value="-1">-- Please Select --</option>
         <c:forEach var="country" items="${countryList}">
            <option value="${country.countryCode}">${country.countryName}</option>
         </c:forEach>
   </select>
   <input type="submit"/>
</form:form>

and here's the code from the controller class, for the methods that handle the 'GET' and 'POST' requests:

Java:
@RequestMapping(value = "/authorsInstitutes", method = RequestMethod.GET)
public ModelAndView displayAuthorsInstitutesForm() {
    ModelAndView mav = new ModelAndView("authorsInstitutes");

    List<Country> countryList = countrySrv.findAll();
    mav.addObject("countryList", countryList);

    return mav;
}

@RequestMapping(value = "/authorsInstitutes", method = RequestMethod.POST)
public ModelAndView displayAuthorsInstitutes(
    @RequestParam(value = "countryCode") String country) {
    ModelAndView mav = new ModelAndView("authorsInstitutes");

    List<Country> countryList = countrySrv.findAll();
    mav.addObject("countryList", countryList);

    if (country != null && !country.trim().equals("")) {
        List<Affiliation> affiliationList = 
            affiliationSrv.getAffiliationsByCountryCode(country);
        mav.addObject("affiliationList", affiliationList);
    }

    return mav;
}

The 'GET' request works fine, but when I select a country and submit the form, I get a 404 error message:

HTTP Status 400 -
type Status report
message
description The request sent by the client was syntactically incorrect ().

I'm sure it's something simple, but for the life of me, I'm just not seeing what it is that I'm doing wrong. I'd appreciate any help on resolving this, thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top