post « MVC « Spring Q&A

1. How can I implement a redirect-after-post form with Spring's AnnotationMethodHandlerAdapter?

I would like to write a @RequestMapping style form controller that redirects after a validation error and round-trips the values and error messages into the GET requested form (the Spring docs ...

2. How to explictely obtain post data in Spring MVC?

Is there a way to obtain the post data itself? I know spring handles binding post data to java objects. But if I had two fields that I want to process ...

3. Spring MVC(Spring 2.5) Question about Post-Redirect-Get

I have a Spring Annonted Controller that is used to capture the information from a form and get a list of search results from the database. Here is the definition ...

4. How does Spring 3 map the form-post in this jsp?

At line 17 of login.jsp, there is the following line of code:

<form action="/login/submit" method="post">
What I can't determine is where Spring submits this form to. In the corresponding, ...

5. Is request.getMethod().equalsIgnoreCase("post") a bad idea in a (pre-Spring-3.0) Spring blog app?

In Spring 3.0 annotations allow you to specify the blog post method as a url. But prior to that version of Spring, is this the best way to achieve it:

public ...

6. spring mvc annotation - object missing values on post

I have a domain object with 5 property. I preload the object in my GET method and display just one of the property in the form. When the form gets submitted, ...

7. Web Flow problems from GET Jsp to a POST JSP (Form) - Spring MVC Annotated

i have a JSP with hyperlink

    <td>Product Name : </td>

8. Request method 'POST' not supported

According to the Spring Documentation here:

While HTTP defines these four methods, HTML only supports two: GET and POST. Fortunately, there are two possible workarounds: you can either ...

9. spring: multiple parameters in one POST

Hi I am using Spring MVC 3 with annotations. How do I use multiple ModelAttributes in one Spring <form:form> tag? It all works perfectly to use one ModelAttribute, but nesting them and using ...

10. Http Post with request content type form not working in Spring MVC 3

code snippet:

@RequestMapping(method = RequestMethod.POST)//,  headers = "content-type=application/x-www-form-urlencoded")
public ModelAndView create(@RequestBody UserAccountBean account) {
        accounts.put(account.assignId(), account);
    }catch(RuntimeException ...

11. Can Spring MVC handle requests from HTML forms other then POST and GET?

Spring 3 MVC supports all 4 of RESTful methods: GET, POST, PUT and DELETE. But does its view technology support them on forms? If not, what is the real use of ...

12. Spring-portlet POST ajax xmlHttpRequest

Could please anybody who has experiences with processing post xmlHttpRequests with Spring DispatcherPortlet, tell me what is the best way to do it ? I'm using YUI io module and Jackson ...

13. POST/Redirect/GET design pattern in Spring MVC

I have a form which submits user first and last name using POST signin.html

 @RequestMapping(value="/signin.html",method = RequestMethod.POST)
 public ModelAndView submit(@Valid User user){
    ModelAndView mv = new ModelAndView("redirect:signin.html"); 

14. listbox null after a post

with spring 3.0 when i click to submit information (post) this method is called here

@RequestMapping(method = RequestMethod.POST)
public String userResult(@ModelAttribute UserForm userForm, Model model) {

    List<UserInfo> listUserInfo = userService.searchUserInfo(userForm.getsearchCriteria());

15. Spring MVC Validation - Avoiding POST-back

I'd like to validate a Spring 3 MVC form. When an element is invalid, I want to re-display the form with a validation message. This is pretty simple so far. The ...

16. How to pass post array parameter in Spring MVC

I was just wondering how to pass in post parameters such as following exercept from html options, normally i would get a array in language such as php (POST['param'][0]... would work ...

17. How to expose a component to receive an XML via POST on Spring 3?

We are using Spring 3.0.3 and I need the body of a POST request. Tried getReader and getInputStream on the request object, but the first one throws an STREAMED exception and the ...

18. optional POST parameter in spring MVC?

I have the following code:

@RequestMapping(method = RequestMethod.POST)
public ModelAndView editItem(String name, String description)
However, sometime description is not passed in (this is a simplified example than the real one), and i would like ...

19. POST data sent by Spring MVC is null on IE8

I have two text fields (pageField1) and pageField2) in Spring MVC where an user can input in page numbers. The javascript code retrieves the values in these textfields and sends as ...

20. Java Spring MVC get/post in same JSP

this is from my controller..

    @RequestMapping(value = "/add", method = RequestMethod.GET)
public String add(Model model) {
    return "add";

@RequestMapping(value = "/add", method = RequestMethod.POST)
public String added(@RequestParam("name") String ...

21. When the validator finds form errors, the form page is redisplayed at the POST url

An item is displayed at this URL:

using this Controller method:
@RequestMapping(value = "/item/{itemId}", method = RequestMethod.GET)
public final String item(HttpServletRequest request, ModelMap model, 
    @PathVariable long itemId)

22. Spring @ModelAttribute, http post parameter conversion fail

I'm getting the below error when trying to submit html option selection form, the selected option value is not converted to the respected enum type. Failed to convert property value of type ...

23. Iterate through form post array in Spring MVC 2

I am trying to iterate through an array sent through a form in the following format:

I am attempting to call: request.getParameter("alarms"), which is returning null. Can someone kindly tell me how ...

24. How to test a HTTP POST of Spring MVC using a web browser?

How can I test an HTTP Post using a web browser? The controller I'm trying to test is an Spring MVC controller.

25. How are POST parameters handled in Spring 3 when some are in URL?

I typically retrieve POST parameters like the following:

@RequestMapping(method = RequestMethod.POST)
public ModelAndView create(
    @RequestParam(value = "first_name", required = false) String firstName,
    HttpServletRequest request
) {
But what if ...

26. How to set all post data in ModelMap in Spring MVC?

I have many input fields in a form to post data to server side. And in controller, I want to get all attributes in ModelMap like this:

public String save(ModelMap model) {

27. Not Able to send the json object to spring MVC ccontroller

I am new to spring MVC and JSON also. I'm trying to send the JSON object to the spring MVC controller but nothing happens when the submit button is pressed. My code ...

28. Post data from Server side in Spring MVC

I am making a automation website to send multiple files to an another site to prevent filling form every time to send a file. I want to to make the POST request ...

29. Spring: Changing Amounts of Form Params

In my application I am loading a list of objects ( we will call them people ) into a table, so I know how many columns there will be for each ...

30. Spring 3.0 FileUpload only with POST?

I am trying to upload a File with one parameter using spring 3. This is my controller method which should enable this service:

@RequestMapping(value="/{id}", method = RequestMethod.PUT, headers="content-type=multipart/form-data")
public ResponseEntity<String> uploadImageWithJsonParamater(@PathVariable("id") Long id, @RequestParam ...

31. HTTP Status 405 - Request method 'POST' not supported

When I submit the JSP form, I get 405 - Request method 'POST' not supported error message in IE. The same application works fine in Google Chrome and Mozilla Firefox but throws ...

32. Spring MVC - Post redirect (PayPal related)

I need to solve a problem with POST redirect in Spring MVC application. PayPal lets you to place a simple html form that can redirect to PayPal pages with post. But I ...


mvc: POST-REDIRECT-GET hi everyone, I'm using the spring MVC framework, and I'm wondering how to do this correctly. I have a website that uses an input form. When errors are found, ...

34. Post processing a ModelAttribute

Hello, When using a model attribute in a controller method Code: public ModelAndView buy(ModelAttribute("pet") Pet pet) { ... } i can initiate the model attribute object in the controller, providing a ...

35. Post To Another Website Using Spring MVC

Thanks for replying. They do not have a REST service. We're being asked to send form content from one of our pages to someone elses server. However, we're supposed to make ...

36. Ajax form post with Spring MVC -> is not displayed

Ajax form post with Spring MVC -> is not displayed Alo I am using spring form taglib. The form is showing in a lightbox so that is why I am ...

37. @ModelAttribute giving error on POST

Hi all, I am using spring 2.5 and I have a controller defined like: Code: @Controller @SessionAttributes("bookingForm") @RequestMapping("/home.htm") public class HomePageController { with two methods: Code: @RequestMapping(method = RequestMethod.GET) protected ModelAndView ...

38. Pre and post request processing with Spring Portlet MVC

Pre and post request processing with Spring Portlet MVC I need to do pre and post processing of all requests to my Spring Portlet MVC application. I am using Vignette Portal ...

39. Spring MVC Redirect after Post for onFormChange

Spring MVC Redirect after Post for onFormChange I am trying to implement the 'redirect after post' pattern in my latest spring mvc project but I am having some problems figuring out ...

40. Do a Post on SuccessView

Hi , I have a successView jsp, which is defined for a controller. What I want to do is that, when I click a hyperlink in successView,I should be able to ...

41. HTTP Post with Spring MVC

HTTP Post with Spring MVC I want to use a Spring controller to Post data from my web application to a separate web application on the same server. Is there any ...

42. Issues with redirect after post + spring mvc

Issues with redirect after post + spring mvc hI, i having a problem with redirect after post solution to double posting. I have a SimpleFormController controller to handle a form submission ...

43. POST to method with multiple ModelAttribute annotations

POST to method with multiple ModelAttribute annotations Hi, I wanted to handle a submitted form via a method like this (somewhat made up): Code: RequestMapping(method = RequestMethod.POST) public String addPetToOwner(ModelAttribute("pet") Pet ...