Announcement Announcement Module
No announcement yet.
Request attributes access from Spring Controller Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Request attributes access from Spring Controller

    Hi, I have a dynamic form xml generated which submits to a Spring controller and, when I try to get any of these attributes, it always comes empty (null value). Exploring the list with the debugger, I see it just contains org.springframework.... classes but no attributes.

    I tried with this example but it doesn't work...
    <form id="8657d801-d9c4-4869-896b-6d8170c871e0" action="../" method='POST'>
    	<input type="text" name="foo" value="bar">
    	<input type="submit" value="Send">
    // Controller 
    @RequestMapping(value = "/", method = RequestMethod.POST)
        public void formSubmit(final HttpServletRequest request, final HttpServletResponse response) throws IOException {
            request.getAttribute("foo"); //<-- always null..
    I'm using Spring 3.1.1.

    Thanks in advance.
    Last edited by abta.amin; Jun 11th, 2012, 03:04 AM.

  • #2
    It isn't an attribute it is a parameter! use getParameter instead.


    • #3
      I'm sorry, i forgot to say I tried to add a new argument with @RequestParam annotation and also using getParameter method. Neither worked. Maybe form fields must be gotten in another way?

      Thanks for your reply.


      • #4
        No they should be there, if they aren't they aren't submitted and you have some sort if issue in your form. Also instead of name try to use id (some browsers use that for identification). If that doesn't work post some actual code/configuration...
        Last edited by Marten Deinum; Jun 11th, 2012, 04:57 AM.


        • #5
          Thanks, it works now. I was set the form enctype to 'multipart/form-data'.