Questions tagged [modelattribute]

315 questions
3
votes
0 answers

Swagger-UI gives null value for @ModelAttribute having multipart form-data

I have an rest API whose request payload is an object(POJO). The structure of the object is defined below: @Data public class ExtractionRequest implements Serializable { private static final long serialVersionUID = -1594766216036852930L; …
Happs
  • 115
  • 7
3
votes
1 answer

Spring Web MVC and newing up beans

We are working on a Spring 3.0.5 Web MVC-based application. In our code we quite often do something like this: @ModelAttribute(ModelKeys.SOME_BEAN) public SomeBean newSomeBean() { return new SomeBean(); } I think this is not necessary. But if it…
Peter Perháč
  • 20,434
  • 21
  • 120
  • 152
3
votes
3 answers

@ModelAttribute always maps Boolean to false

when I try to map Boolean value from url to spring controller, it always map to false. This is my url http://localhost:8080/myurl?isFirstTime=true here is my controller @RequestMapping(value = "/myurl", method = RequestMethod.GET) public…
user9735824
  • 1,196
  • 5
  • 19
  • 36
3
votes
1 answer

Spring MVC update ModelAttribute value

When modifying a ModelAttribute that is listed as a SessionAttribute, why doesent it keep its new value? Every time I make a request to the example below, it prints out "Initial value.", which is a correct value for the first request. But after the…
Gábor DANI
  • 2,063
  • 2
  • 22
  • 40
3
votes
1 answer

Adding model attribute to spring MockMvc call

I'm writing a test for a simple controller. The controller checks if the modelattribute "ADDED_OBJECT" exists and returns a success page and an error page when the modelattribute is missing. Testing the error path is no problem but I don't know how…
Patrick Adler
  • 196
  • 2
  • 9
3
votes
1 answer

Spring ModelAttribute correct parsing

I have Spring controller with endpoint like: @RequestMapping("/provider") public ResponseEntity load(@ModelAttribute PageRequest pageRequest) { ... //do something } where PageRequest is simple POJO: class PageRequest { String[]…
Bublik
  • 912
  • 5
  • 15
  • 30
3
votes
1 answer

Django: Can't access model attributes

Lately I started using my existing mysql database in Django. Implementing it worked The database settings looks like this DATABASES = { 'default': { 'NAME': 'app_data', 'ENGINE': 'django.db.backends.sqlite3', }, 'users': { 'NAME':…
3
votes
0 answers

Making @ModelAttribute annotation to accept form-data instead of x-www-form-urlencoded

I am using spring webmvc for my project, and there i am using @ModelAttribute annotation in controller action to bind the form data to model. ModelAttribute is binding data fine if i am sending data in x-www-form-urlencoded form.But if i am sending…
vivex
  • 2,496
  • 1
  • 25
  • 30
3
votes
2 answers

KnockoutJS - Print iteration index as input name

I am trying to create my first KnockoutJS form view in combination with Spring MVC's @ModelAttribute binding. Data is loaded over Ajax and populated with KnockoutJS Data is added over KnockoutJS Data is removed over Ajax and KnockoutJS Data will…
Tunguska
  • 1,205
  • 3
  • 18
  • 37
3
votes
2 answers

How to disable some request calling @ModelAttribute method in the same controller?

I am using Spring3 MVC. In my controller, I have many methods such as create, edit, and search. In my form in the view, I need a list which contains some values from db. So I add a following method ``` @ModelAttribute("types") public…
Chris
  • 6,431
  • 10
  • 44
  • 59
3
votes
1 answer

Spring multiple @ModelAttribute methods in the same @Controller

I have a page with two different forms (with two different submits) on Spring MVC 3, and I have a problem with @ModelAttribute methods. When I have two on the same controller, they are not always executed making the model to be NULL. The…
droidpl
  • 5,872
  • 4
  • 35
  • 47
3
votes
1 answer

Returning a Spring Model in a @ModelAttribute annotated method

Can I use a Spring model as a model in a method annotated with the @ModelAttribute? I get an error saying it can't find the attribute in the model. Here is the method where I add my object to the model: @ModelAttribute("survivor") public Model…
bretter
  • 441
  • 7
  • 12
3
votes
1 answer

Spring 3 @ModelAttribute with List in model

I have two models : public class Size { private String name; // getter and setter } public class Product { private int id; private String designation; private Float price; private List availableSizes; //…
3
votes
3 answers

Omit ModelAttribute from view

I have a rest application that returns json/xml. I use jackson and jaxb for conversion. Some methods need to accept a query_string. I've used @ModelAttribute to map the query_string into an object, but this forces the object into my view. I do…
John Vinopal
  • 551
  • 4
  • 11
2
votes
2 answers

Spring MVC object passed with model attribute is empty

i have problem with @ModelAttribute, CustEntity have objects like "name" etc. also have list of BankAccEntity called bankAcc which has number and name. in GET method when i use getBankAcc() my cust has arraylist with bankaccounts, but when i pass…
user1199476
  • 121
  • 2
  • 5
  • 11
1 2
3
20 21