Questions tagged [spring-mvc-initbinders]
65 questions
                    
                    12
                    
            votes
                
                2 answers
            
        org.springframework.validation.BeanPropertyBindingResult Exception
Hi I am a new to spring framework. I have done a small example where I tried to validate my input field using spring validation api. This is the code
@RequestMapping(value = "/applicationFormSubmit", method = RequestMethod.POST)
    public String…
         
    
    
        Chandan Sarma
        
- 308
- 2
- 5
- 19
                    11
                    
            votes
                
                3 answers
            
        Customize mapping request parameters and fields inside the DTO ?
I have the following class:
public class MyDTO { 
       private String kiosk;
       ...
}
and following url:
http://localhost:1234/mvc/controllerUrl?kiosk=false
and following controller method:
@RequestMapping(method = RequestMethod.GET,…
         
    
    
        gstackoverflow
        
- 36,709
- 117
- 359
- 710
                    7
                    
            votes
                
                0 answers
            
        How to setup FORM binding in Spring MVC 4.3 to have in controller an appropriate child object of the inheritance tree
I'm making changes in a very old application. which is using Spring MVC 4. 
I need to post data from a form:form tag within in JSP for Spring controller.
UI is fixed and I can only make changes at server side.
Based upon a specific field in my…
         
    
    
        ThrowableException
        
- 1,168
- 1
- 8
- 29
                    7
                    
            votes
                
                1 answer
            
        Spring mvc miss id of dependent collection when combine form object from jsp
I have following controller to return view:
@RequestMapping(value = "/admin/adminUsers", method = RequestMethod.GET)
    public String adminUsers(ModelMap model, HttpSession session) {
        Set users =… 
         
    
    
        gstackoverflow
        
- 36,709
- 117
- 359
- 710
                    6
                    
            votes
                
                1 answer
            
        AspectJ: Autowired fields are null in Initbinder
I just implemented AspectJ like described here: https://stackoverflow.com/a/10998044/2182503
This solution works fine, until I noticed that my @Autowired fields are null within @InitBinder. The fields are only null within the…
         
    
    
        Tunguska
        
- 1,205
- 3
- 18
- 37
                    5
                    
            votes
                
                1 answer
            
        Failed to convert value of type 'org.springframework.web.multipart.commons.CommonsMultipartFile' to required type
I have following controller method:
@RequestMapping(value = "/owner/terminals/save", method = RequestMethod.POST)
public String saveTerminal( @RequestParam(value = "name") String name, 
                            @RequestParam(value = "file")…
         
    
    
        gstackoverflow
        
- 36,709
- 117
- 359
- 710
                    4
                    
            votes
                
                2 answers
            
        Why the @InitBinder method is called for every request?
While I was debugging my Spring Boot application I noticed that methods annotated with @InitBinder are invoked for every incoming request.
@InitBinder("categories")
public void bindFields(WebDataBinder binder) {
   …
         
    
    
        Mahozad
        
- 18,032
- 13
- 118
- 133
                    4
                    
            votes
                
                3 answers
            
        @Valid annotation is ignored when applied to MultipartFile object
This is my controller. It accepts a multipart/form-data request with two fields, form and file. The form field is a 
MyObject, the file field is a MultipartFile. Both variables are annotated with @Valid, and accordingly, I would expect Spring to…
         
    
    
        Magnus
        
- 589
- 8
- 26
                    4
                    
            votes
                
                1 answer
            
        Renaming a nested property of a Spring MVC model attribute
I have the following form:
public class ChildcareWorkerAdvertisementForm extends AbstractForm {
    @Valid
    @Override
    //Rename the property from "model" to "advertisement"?
    public… 
         
    
    
        balteo
        
- 23,602
- 63
- 219
- 412
                    3
                    
            votes
                
                1 answer
            
        Configure two @InitBinder to work with the same Model or Entity but for different @RequestMappings
I have a controller where works fine, It can register and update an entity, just how the following about to create the forms to save and update an entity respectively
@RequestMapping(value="/registrar.htm", method=RequestMethod.GET)
public String…
         
    
    
        Manuel Jordan
        
- 15,253
- 21
- 95
- 158
                    3
                    
            votes
                
                2 answers
            
        How to specify custom validate error message in SimpleDateFormat using Spring MVC
In my Smpring MVC application I'm validating dates using SimpleDateFormat as a custom editor in WebDataBinder. When entered date does not match required pattern I get raw error message in my form:errors tag like:
Failed to convert property value of…
         
    
    
        Zarial
        
- 283
- 3
- 11
                    3
                    
            votes
                
                2 answers
            
        Spring StringTrimmerEditor trim all fields except password field
In registered a StringTrimmerEditor in a Spring controller.
Of course when I now enter a password starting or ending with whitespace it is trimmed as well. But an user doesn't recognize this trimming.
@InitBinder
public void initBinder(WebDataBinder…
         
    
    
        Marcel Binder
        
- 166
- 10
                    3
                    
            votes
                
                1 answer
            
        How to define multiple initBinders
Would it be possible to have multiple initBinder Methods inside a single Controller? Where each InitBinder() (see code) depends on a unique request handler e.g. initBinder() is called on url: "/update/account" and initBinderOne() on…
         
    
    
        James White
        
- 41
- 2
- 4
                    3
                    
            votes
                
                1 answer
            
        Spring MVC Hibernate Validator TypeMismatch Exception
I'm using Spring MVC with Hibernate validator 4.2.0. have a ValidationMessages.properties on my class path in /WEB-INF/classes/ValidationMessages.properties:
typeMismatch.java.lang.Integer=Must specify an integer value.
typeMismatch.int=Invalid…
         
    
    
        JimJay
        
- 349
- 2
- 8
- 17
                    3
                    
            votes
                
                1 answer
            
        Spring MVC 3 Controller annotation for onBind() - how to?
I am upgrading from Spring 2.5 to Spring 3.2. I have a MVC Controller that previously extended CancellableFormController. It declared,separately, initBinder() and onBind() methods. I have refactored the Controller to use @Controller annotation, and…
         
    
    
        arcseldon
        
- 35,523
- 17
- 121
- 125