I know this works where the url contains the parameter 'deleteItem=6'
@ActionMapping(params="deleteItem")
public void deleteItem(@ModelAttribute("items") Items items, BindingResult bindingResult, @RequestParam int deleteItem) throws Exception {
items.getItems().remove(deleteItem);
...
}
but can I do something like this (use the value of the deleteItem parameter:
@ActionMapping(params="deleteItem={idx}")
public void deleteItem(@ModelAttribute("items") Items items, BindingResult bindingResult, @RequestParam int idx) throws Exception {
items.getItems().remove(idx);
...
}
No biggie, it's that the code is more readable because it shows that the parameter value is an index.
Thanks.
No, you can't use a dynamic param as a binding name like this @ActionMapping(params="deleteItem={idx}")
because Spring Portlet MVC needs to bind a method to an action with a unique name.
Your first snippet is correct.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.