zaxx
zaxx

Reputation: 285

Request parameters in Spring MVC

How to pass it, when I got these configuration:

    <servlet>
    <servlet-name>spring</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>spring</servlet-name>
    <url-pattern>*.htm</url-pattern>
</servlet-mapping>

In my controller:

@RequestMapping(value="/list.htm", method=RequestMethod.GET)
public ModelAndView list(HttpServletRequest request,
        HttpServletResponse response, @RequestParam(value="start", required=false) String start, @RequestParam(value="end", required=false) String end)throws Exception{
        ModelMap modelMap = new ModelMap();
        modelMap.addAttribute("list", cpvCodeDAO.list(Integer.parseInt(start),Integer.parseInt(end)));
        return new ModelAndView("list", modelMap);
}

When i put: "http:... /list.htm?start=0&end=100" I got error stacktrace like this:

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalArgumentException: wrong number of arguments org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:625) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:525) javax.servlet.http.HttpServlet.service(HttpServlet.java:621) javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

Upvotes: 0

Views: 1785

Answers (1)

Tom Hartwell
Tom Hartwell

Reputation: 668

Are you still looking for an answer on this? I pulled your code into a controller and it worked fine in my environment, no stack trace.

I'm using Spring's and and then have my controller annotated with @Controller

My guess is it's not your method but your configuration that's causing the failure, but w/ the limited info you've included above, it's hard to say.

What does your spring-servlet.xml look like?

Upvotes: 1

Related Questions