1

I have a login page with form action of j_security_check. As of now this form just have two fields namely username and password. I want to add a new dropdown to this form and collect the selected value in controller using @RequestParam. For some reason I am not able to pass this dropdown value from JSP to my controller as its throwing the exception: MissingServletRequestParameterException (Which occurs anytime a request param is missing).
In the code below I added the Visuals dropdown. Do I need to use Spring:Bind tag here? Also on successful login, the control is directed to a controller with request mapping /controller1.html and this is where I am trying to collect the dropdown value.

<form name="appLogin" action="j_security_check" method="POST">

<table width="100%">
    <tr>
        <td align="center">

        <table>
            <tr>
                <td>Username: </td>
                <td><input id="userName" name="j_username" value=""/></td>
            </tr>
            <tr>
                <td>Password: </td>
                <td><input name="j_password" type="password" value="" /></td>
            </tr>

                <tr>
                <td>Visual: </td>
                <td><Select name="visuals" id="visuals"/>
                      <option value="S1">S1</option>
                      <option value="S2">S2</option>
                      <option value="S3">S3</option>
                      <option value="S4">S4</option>
                    </Select>
                </td>
            </tr>

        </table>

        <table>
            <tr>
                <td>
                <button type="submit" name="submit" value="Sign In">Sign In</button>
                <input type="submit"/>
                </td>
            </tr>
        </table>
        </div>
        </div>
        </td>
    </tr>
</table>
</form>

Controller Code:

 @RequestMapping( value = " /controller1.html", method = RequestMethod.GET )
    public String setupForm( @RequestParam(value = "visuals", required=false) String visuals,
            ModelMap model )
    {
        List<String> studentNames = new ArrayList<String>();
        List<String> teacherNames = new ArrayList<String>();


         model.addAttribute("someData", teacherNames);
         model.addAttribute("anotherData", studentNames);

        model.addAttribute("visuals", visuals);

        log.info("Role from Dropdown:  " + visuals);

        return "school/classTen";
    }
5
  • and what does the controller method with the @RequestParam look like? Commented Jul 26, 2011 at 2:56
  • Its just a simple method that returns couple of ArrayLists. Commented Jul 28, 2011 at 19:32
  • I ask because without knowing what the controller method looks like this is incredibly hard to troubleshoot. Commented Jul 28, 2011 at 19:39
  • Matt, give me few. I will post the controller method. Commented Jul 28, 2011 at 19:49
  • Matt I added the controller code. Commented Jul 28, 2011 at 19:58

1 Answer 1

1

You need to create yyour own Filter by extending AbstractAuthenticationProcessingFilter

I don't have the entire code in front of my eyes, but the following article could help you:

http://mark.koli.ch/2010/07/spring-3-and-spring-security-setting-your-own-custom-j-spring-security-check-filter-processes-url.html

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.