Two submits in one JPS and two actions in Spring

I know this question has been asked and answered but I don`t seems to have found a solution.

<form:form method="post" action="my.htm" modelAttribute="someForm">
    <div class="rightAlign"><input type="submit" value="something" name="something"/></div>
    <div class="rightAlign"><input type="submit" value="delete" name="delete"/></div>
</form:form>

How should I map it in controller?

 @RequestMapping(method = RequestMethod.POST, params="/delete")

or

 @RequestMapping(method = RequestMethod.POST, value="/something")

Answers


Form's action corresponds to RequestMapping's value parameter, name of the input field will be used as the name of the HTTP parameter, use the params element to "catch" it. The correct RequestMapping configuration to filter by form's content would be:

@RequestMapping(value="my.htm", method=RequestMethod.POST, params="delete")

and

@RequestMapping(value="my.htm", method=RequestMethod.POST, params="something")

(It's all in the documentation)


Need Your Help

Android app data security

android security storage sd-card

I am downloading files from a remote server to be saved for use on an android device. These files are mostly images and audio but I would like it so that a user cannot access this data using methods

HTTP Status 500

java netbeans rest

I want to make Restful - Web Service using netbean 6.5, glassfish V 2 , and i already make table and the relationship between table. But when i want to test restful Webservice, some table it show

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.