Parameter « MVC « Spring Q&A

1. Best way to validate URL parameters in Spring MVC website?

I am using Spring MVC to build my web application, and I have a question about validating parameters I receive in the URL. What is the best way to detect invalid ...

2. Data binding of @ModelAttribute annotated parameters

I have a Spring 2.5 annotated Controller in which I have a method annotated with @RequestMapping(method=RequestMethod.GET), which performs some logic to fill the model. I also have a method annotated with @RequestMapping(method=RequestMethod.POST) ...

3. How does ThrowawayController in Spring MVC get the parameters from a request?

This is an example of using ThrowawayController in Spring MVC:

public class DisplayCourseController 
    implements ThrowawayController {
  private Integer id;
  public void setId(Integer id) { = ...

4. Spring MVC binding parameters to backing object

I am using Spring MVC and in my controller, I want to be able to automatically bind incoming parameters to my Java object. It seems like this should be pretty easy ...

5. Spring MVC 3 - Binding parameters to backing object

I am trying to setup an edit form for my User object. I have automatic binding from the form to the user object working fine. I'm wondering how do I prevent ...

6. Request parameters in Freemarker on Spring 2.5

I am trying to get request parameters on freemarker page. But I can't figure out how to setup implicit variables like RequestParameters or so. Here is a thread ...

7. using http request parameters in spring mvc

I am generating a table of data from a simple list of objects that I am displaying in a jsp page. Each row has a View hyper link attached to it. ...

8. Spring MVC JSP Parameters

I'm looking to turn off try blocks for a specific JSP page (though turning it off globally would be OK as well). From what I've gathered, it looks something like this:

However, ...

9. Render different tile baseon request parameter (Springframework & tiles)

I need to change some existing application to render different view depending on some request parameter. This application is using tiles. I never used tiles before, and need a bit of ...

10. Spring MVC - Set an actionURL parameter with Javascript

Is it possible to dynamically set a Spring MVC portlet:actionURL portlet:param using javascript? I have tried with the following code, but the id value always comes across as null to ...

11. Spring MVC - Cannot map request parameters as a Map parameter in method?

What I want to do is passing a map to the method in Controller using @RequestParam, but it seems not working. While this is working in Struts 2 as value ...

12. Bind multiple request parameters to one object in Spring 3

I can't figure out a way to bind several arguments and headers to one request parameter using annotations in Spring 3. For example, let's say I'm getting this request:

Content-type: text/plain;

POST Body:
Name: Max
Now ...

13. How to add context parameter after loading spring context

I want to add a servlet context parameter/attribute through spring configuration. I need this because the value I want to add in servlet context is available only after spring container loads. ...

14. Custom property editors do not work for request parameters in Spring MVC?

I'm trying to create a multiaction web controller using Spring annotations. This controller will be responsible for adding and removing user profiles and preparing reference data for the jsp page.

public class ...

15. difference between using and not using @modelAttribute in method parameter

I am new to spring mvc and have seen examples where folks use @ModelAttribute("form") Person person in method parameter and some who just do (Person person). what is the difference. Thanks in ...

16. Map multiple request parameters

i'm sending two parameters using GET (through URL) and woul like my request method to receive them like this ...

public String basketItems(
    @RequestParam("fname") String firstName, 

17. Validate format parameter via config in Spring MVC

Here is my situation: I have my mvc-config.xml file for my web service set up to have JSON as the default media type. I also have favorParameter for the ContentNegotiatingViewResolver as true. ...

18. Using both @RequestBody and normal parameters

I am using spring 3 controllers with a flex client. I am now using @RequestBody in order to pass xml's to the server. How can i pass additional parameters? Thank you.

19. JSP/servlet read parameters from properties file?

My JSP pages need to display different information depending on which environment they're in (dev, production, sandbox, etc). I want to have a properties file for each of these environments ...

20. @ModelAttribute parameter not being populated

I have a controller in which I have a GET method display a form POJO, which is to be captured by a corresponding POST. However, when the POST request is executed, ...

21. Pass a request parameter in Spring MVC 3

I just want to send the value of my dropdownlist with a requestparameter. In my case being

I know a way of doing this but it sounds so irrational to use ...

22. Spring Portlet MVC: Forward Request parameters to model

I got two views:

  1. Displays some common information about an entity
  2. Displays more details about this entity
The second view has a link back to the first one. To create the link I need ...

23. requesting parameters from jsp

I have some problems with taking a parameters from jsp page, when method POST occurs. My JSP page looks like this:

<table border="1">

24. Problem with using custom JSR303 annotation to validate method parameter in Spring mvc container

I build a simple application using Spring, and I try to implement a custom JSR303 annotation to validate method string parameter. I use Java code to config Spring container and I ...

25. How can I trim whitespace from request parameters in Spring MVC

I'm struggling to believe that my need to trim leading and trailing whitespace from request parameters is not a common requirement, and yet I can't seem to find anyone who has ...

26. spring portlet mvc: keep parameters

In my first render function I add a an object to my model, and in my JSP I display it using el ${user.firstname}. However when I submit my jsp the handling ...

27. What is the best way to create and use an initializaion file with parameters while doing a springmvc web project?

I want to create a initilisation file in my spring-mvc web project . What is the best way to do it so that i will be able to get thoses value ...

28. Spring @ModelAttribute and translating request parameter binding names

I'm working on converting a legacy project to Spring (trying to adjust little as possible for now) and I'm running into a small issue with mapping/translating legacy parameters to a model ...

29. How to prevent parameter binding from interpreting commas in Spring 3.0.5?

Consider the following controller method:

@RequestMapping(value = "/test", method = RequestMethod.GET)
public void test(@RequestParam(value = "fq", required = false) String[] filterQuery) {
    logger.debug(fq = " + StringUtils.join(filterQuery, "|"));
Here is the ...

30. Spring Passing request parameter

I want to pass parameter (a String value) to spring controller from a jsp What is the best or recommended way to do it. -I don't want to send parameters in URL - ...

31. Language parameter on the link

exists an easy method to have the language always at first in the link without change every controller in Spring MVC? For example

and this language parameter pass automatically "language=en". I'm using LocaleChangeInterceptor

32. How to ensure URL parameters map to right field in Spring MVC?

Say I have two independent classes:

class Foo {
   int bar;

class Baz {
   int bar;
and I want to accept an instance of each in Spring MVC controller:
public ModelAndView ...

33. Spring MVC 3: How to customize split-pattern for request parameter

my problem is that I have the following URL:

http://localhost:8080/shiSolrClient/app/shi/search?q=xyz&fq=author:"Max, Muster"
I have a bean that maps these requestParameters:
public class SearchParams {

    private String q = "";

34. @Autowired property in bean constructed as MVC method parameter

I'm using the Spring MVC framework. In the code fragment below, is it possible for me to have Spring inject a bean into the MyRequestClass request parameter when it is constructed ...

35. Can I return ModelAndView with parameters?

I must return address myaccount.htm#box-two with modelMap. "#box-two" is very impurtant for me, when I put:

return new ModelAndView("redirect:myaccount.htm#box-two", modelMap);
it doesn't work, I got my parameters in my url: "http://localhost:8080/RestFinderWebApp/mojekonto.htm?nameError=Name+required#box-two" I tried also:

36. Spring mvc url parameter

I cannot display may restaurant. got my controller class:

public class RestaurantController extends MultiActionController{

    private RestaurantDAO restaurantDAO;

    public void setRestaurantDAO(RestaurantDAO restaurantDAO) {

37. How do I use @Valid with Spring MVC's @RequestBody parameters?

I'm having an issue with using @Valid on a parameter to a handler method on my @Controller. My code looks like this:

@RequestMapping(value=BIBBLE_BOBBLE_URI_PATTERN + "/widgets", method=RequestMethod.POST)
public Widget saveNewWidget(

38. Spring MVC customized method parameter binding

I'm looking for a way to customize the default Spring MVC parameter binding. Take this method as an example:

public ModelAndView doIndex(@RequestParam String param) {
This is easy, when I have ...

39. Spring MVC - Request mapping, two urls with two different parameters

Is it possible in Spring to have one method with two different urls with different params for each method? Below is pseudo code @RequestMethod(URL1-param1, URL2-param2) public ...

40. SpringMVC request parameter conversion

I can use property editors in SpringMVC to do custom conversion of a request parameter. For example to convert a request parameter to an instance of Foo below

public class Foo {

41. Spring Convertor or Property editor for conversion of multiple request parameters into an Object?

Concrete example would be implementation of a Convertor/PropertyEditor for (2011, 11, 24, 8, 10, AM) request parameters to Date object ? Let say that my UI uses a widget that uses 6 ...

42. How to do spring request parameter conversion

In a Spring 3 based web (portlet) application I have a controller with a method like this:

public ModelAndView handleRenderRequest(...,@RequestParam MyClass myObject)
Now I wonder: How do ...

43. Request parameters in Spring MVC

How to pass it, when I got these configuration:


44. Spring - ModelAttribute and parameter names

How I can configure Model/Command class to bind to specific request parameters? For example i have following method:

ModelAndView success(@ModelAttribute SomeCommand command) {
   // process
and command:
class SomeCommand {
   String ...

45. Spring MVC: With SimpleMappingExceptionResolver, what parameters are passed to the view

I've implemented SimpleMappingExceptionResolver. I want to embed the exception text in an HTML comment, how can I access the exception from the View?

46. How to send parameters to JSP and get them back updated in Spring MVC

I'm new to Spring MVC and JSP developing, so please be gentle telling me I'm doing something stupid :P Told that, the question: I studied a bit Spring MVC and got a nice ...

47. url parameter set by label value in Spring MVC

Is there any way to make form url parameter submit by value of label? I mean, I want to do simple search form like this:

<form:form action="">
<input type="text" id="search" name="search"> <input type="submit" value="Search">
How ...

48. SpringMVC: Customize naming strategy of parameter returned to view

As far as I know it's possible to have a controller method return an arbitrary object (instead ModelAndView). Spring will than map the method to a view as specified by url ...

49. Spring Web MVC error handling for non binded parameters

I am using spring web mvc for registering an user. But my User class has a variable of type Website.

public class User{

private String email;

private WebSite website;


public class WebSite{

private String webSiteUrl;

In my ...

50. Spring 3 MVC - Map request parameters with prefix to a single bean

I have the following GET request: /api/search?filter.operation=Ping&filter.namespace= Please note the parameter names include a prefix (filter. operation, filter. namespace). Then, I have the following bean I want to use to receive those parameters:

class MessageSearchFilter ...

51. spring mvc 3 dynamic request parameters

I am using for some nice paged tables. However, some of the server-side features require me to deal with dynamically named GET parameters. So for example:

bool bSearchable_(int) Indicator ...

52. Spring - Abstracting url mapping to handle common url parameters

Assume the following setup: We have multiple commands mapped to different URLs, each of these with its own body, which we can capture using mappings, like:

@RequestMapping(value = "url1/{param}/command", method = RequestMethod.POST)
public ...

53. Passing the model Map as Xslt stylesheet parameters

Hi, I am implementing the AbstractXsltView class. In the Spring Doc sec - "Adding stylesheet parameters" it is stated that if I want to pass parameters to a XSLT ...

54. Issue with populating command object using request parameters using Spring MVC 2.5

Issue with populating command object using request parameters using Spring MVC 2.5 I'm currently trying to validate some variables with Spring 2.5. I am taking in six POST parameters and setting ...

55. Spring MVC 3: How to customize split-pattern for request parameter in URL

Spring MVC 3: How to customize split-pattern for request parameter in URL Hi everyone, my problem is that I have the following URL: Code: http://localhost:8080/shiSolrClient/app/shi/search?q=xyz&fq=author:"Max, Muster" I have a bean that ...

56. Spring MVC 3 - Binding multiple form parameters of the same name?

Hi there, Is it possible to Bind multiple parameters of the same name to a form object with Spring MVC 3? Can it be bound to an ArrayList of values for ...

57. How do I pass a parameter to a successView?

How do I pass a parameter to a successView? I have a list page that takes a query string parameter (userListForm.htm?groupId=123). When someone clicks on a username in the list page, ...

58. successView and parameters

successView and parameters Hello all. I have a question about InternalResourceViewResolver. I have a Controller which expects an id by parameter to retrieve an object from database through my DAO and ...

59. passing of parameters on Spring MVC

im a student and my project is to display the list of persons[, user.issued] under user.division. They would choose the user.division in a drop down list [userForm.jsp.] how can i pass ...

60. Passsing Http FORM parameters from Java to Spring MVC

Passsing Http FORM parameters from Java to Spring MVC Hi, I have inherited a Sping MVC application that processes Http FORM elements submited to it from an HTML page's doPost request. ...

61. AbstractJasperReportsSingleFormatView, model parameters override "createExporter()"

Hi all, I'm facing a problem when using JasperReports in a project with Spring. I'd like to use an implementation of the abstract AbstractJasperReportsSingleFormatView, defining my own createExporter() method with my ...

62. How can I pass parameters to an applet in spring MVC model?

Hi, How can I pass parameters to an applet in spring MVC model? I want to call an applet and pass parameters to it. The parameters are from another form view. ...

63. Where to add parameter in ModelAndView?

hi, I am using Spring for JasperReport. For setting ModelAndView, I added datasource to its map.. But I have no idea about where to add parameter... (parameter is a hashMap) Can ...

64. Spring MVC: Issue with populating command object using request parameters

Spring MVC: Issue with populating command object using request parameters We are using AbstractCommandController to capture all the request parameters into a command object however the value is not getting auto ...

65. Model parameters not showing in jsp

Jun 23rd, 2009, 09:06 AM #1 tmor82 View Profile View Forum Posts Private Message Junior Member Join Date Jun 2009 Posts 5 Model parameters not showing in jsp Hi all, I ...

66. Use springmvc annotation on how to pass the same parameters on each page

Use springmvc annotation on how to pass the same parameters on each page Code: @Controller @RequestMapping("/") public class BaseClassController { @RequestMapping(params = "action=main") public String main(ModelMap model,HttpServletRequest request) { model.addAttribute("pageSize", ProjectConstants.PAGE_SIZE); ...

67. Multiple @ModelAttribute in a method parameter

Multiple @ModelAttribute in a method parameter Hi, I am new to Spring 2.5 and trying to learn. I have a basic question, suppose I have two VO person and address, and ...

68. Send Parameter using ModelAndView.

Hi, Im needing to redirect the page using the Spring MVC, and actually this redirect is made using the requestDispatcher. this peace of code is in my servlet. String itemLink = ...

69. model parameters in a forward:

model parameters in a forward: For a bit, some of our code (usually when talking to legacy struts code, but also some spring code) would do something such as: ModelAndView mv ...

70. MVC - Problem binding parameters

MVC - Problem binding parameters Hello, Im having a strange problem related to the way Spring MVC(v:3.0.1) binds request parameters to objects. More specifically, lets assume we have the following class ...

71. Passing a list as a parameter to ModelAndView

Passing a list as a parameter to ModelAndView I was wondering if anyone knows how to pass a list of model objects as a parameter to the ModelandView method in the ...

72. Spring Portlet MVC: Forward Request parameters to model

Spring Portlet MVC: Forward Request parameters to model I got two views: Displays some common information about an entity Displays more details about this entity The second view has a link ...