0

I use a modelattribute in my form and controller.

<form:form action="/admin/editingBook" modelAttribute="editingBook">
...
...
</form:form>

Controller

@RequestMapping(method = RequestMethod.POST, value = "/admin/editingBook")
public String updateBook(@ModelAttribute BookBean bookBean) {
}

I would like to add an information who are not in my modelAttribute, something like

@RequestMapping(method = RequestMethod.POST, value = "/admin/editingBook")
public String updateBook(@ModelAttribute BookBean bookBean, @RequestParam("bookName") String bookName) {
}

not sure how to do it on the jsp side and controller side

Sotirios Delimanolis
  • 274,122
  • 60
  • 696
  • 724
robert trudel
  • 5,283
  • 17
  • 72
  • 124
  • Add it as a request parameter. Simply add a hidden field with the name 'bookName' and it will be passed as a request parameter. Or using javascript add it to the URL `${baseUrl}+?bookName=${yourBookName}` – M. Deinum Nov 02 '13 at 09:29

1 Answers1

0

Where the book name would come?

Controller side :

 @RequestMapping(method = RequestMethod.POST, value = "/admin/editingBook/{bookName}")
    public String updateBook(@ModelAttribute BookBean bookBean, @RequestParam("bookName") String bookName) {
    }
kyla
  • 396
  • 1
  • 8
  • what if you set attribute in http request scope, pass the request and retrieve the attribute? – kyla Nov 01 '13 at 19:53
  • i tried var oldBookTitle = $('#bookTitle').data('old-book-tile'); $('#editingBook').submit(function() { $(this).attr("action", "${editBoolUrl}" + oldBookTitle); $(this).dialog('close'); }); but nothing is called on the server side – robert trudel Nov 01 '13 at 21:21
  • that is not proper way to append, here take a look at this: 1)for proper call to make ajax http://www.raistudies.com/spring/spring-mvc/ajax-spring-mvc-3-annonations-jquery/ 2) how to append additional data for the call http://stackoverflow.com/questions/2530635/jquery-add-additional-parameters-on-submit-not-ajax – kyla Nov 04 '13 at 15:47