Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7928957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T19:54:27+00:00 2026-06-03T19:54:27+00:00

I create form and controller this form have some validation constrains using Hibernate validator.

  • 0

I create form and controller this form have some validation constrains using Hibernate validator. I face problem when starting test the validation constrains but I got Blue Exception page with the attributemodel with the rejected.

This the configuration

    @Configuration
    @ComponentScan(basePackages = {"com.whatever.core.web"})
    @EnableWebMvc
    public class WebMvcConfig extends WebMvcConfigurationSupport {

private static final String MESSAGE_SOURCE = "/WEB-INF/classes/messages";
private static final String TILES = "/WEB-INF/tiles/tiles.xml";
private static final String VIEWS = "/WEB-INF/views/**/views.xml";

private static final String RESOURCES_HANDLER = "/resources/";
private static final String RESOURCES_LOCATION = RESOURCES_HANDLER + "**";



@Override
public RequestMappingHandlerMapping requestMappingHandlerMapping() {
    RequestMappingHandlerMapping requestMappingHandlerMapping = super.requestMappingHandlerMapping();
    requestMappingHandlerMapping.setUseSuffixPatternMatch(false);
    requestMappingHandlerMapping.setUseTrailingSlashMatch(false);
    return requestMappingHandlerMapping;
}

public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
    converters.add(new MappingJacksonHttpMessageConverter());
}

@Bean(name = "messageSource")
public MessageSource configureMessageSource() {
    ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
    messageSource.setBasename(MESSAGE_SOURCE);
    messageSource.setCacheSeconds(5);
    return messageSource;
}

@Bean
public TilesViewResolver configureTilesViewResolver() {
    return new TilesViewResolver();
}

@Bean
public TilesConfigurer configureTilesConfigurer() {
    TilesConfigurer configurer = new TilesConfigurer();
    configurer.setDefinitions(new String[] {TILES, VIEWS});
    return configurer;
}

@Override
public Validator getValidator() {
    LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
    validator.setValidationMessageSource(configureMessageSource());
    return validator;
}



@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
    registry.addResourceHandler(RESOURCES_HANDLER).addResourceLocations(RESOURCES_LOCATION);
}

@Override
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
    configurer.enable();
}
    }

and the controller here

    if(result.hasErrors()){
        return null; OR "view name"
    }
    User user = new User();
    user.setUsername(userModel.getUsername());        
    user.setFirstName(userModel.getFirstName());
    user.setLastName(userModel.getLastName());
    user.setGender(userModel.getGender());
    user.setLocation(userModel.getLocation());
    user.setPassword(passwordEncoder.encodePassword(userModel.getPassword(),null));

    userRepository.save(user);
    doAutoLogin(userModel.getUsername(),userModel.getPassword(),request);
    return "redirect:/home";

NOTE: I use springMVC, spring security, tiles, and hibernate validator

I used SpringMVC with hibernate validator with XML configuration and portal environment and work fine I don’t know what the wrong here!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T19:54:29+00:00Added an answer on June 3, 2026 at 7:54 pm

    I Found the issue! the signature of the method controller should be like this

        public String signup(@ModelAttribute("userModel") @Valid SignupForm userModel,BindingResult result,HttpServletRequest request,HttpServletResponse response,ModelMap model)
    

    as what I read in sprinsource forum, the BindingResult should follow the modelAttribute and work find. I didn’t find any official documentation for this but its work now.

    to see the thread of springsource forum check this link http://forum.springsource.org/showthread.php?85815-BindException-Thrown-on-bind-errors-(instead-of-returning-errors-to-controller-method

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a namespaced controller for some admin functionality. My create form does not
I have a Form element: $Form=new Zend_Form; $Form->setAction($this->view->url(array('controller'=>'auth','action'=>'create'),null,true)) ->setMethod('post') ->setAttrib('id','auth-form') ->removeAttrib('enctype'); As can be
I have a create action in the controller that I use for a form
Say you create a form using ASP.NET MVC that has a dynamic number of
I would like to test the validation of submitted DTO. This is the bare
i'll try and be as clear as possible. I'm working on some form validation
Hey guys I have a simple create method with some validations and whenever the
Currently I have the usual Controller/Action structure: BlogController: /blog/list /blog/create /blog/detail/my-blog-hash And PostController /post/create
I have a Controller called Register that looks like this: class Register extends CI_Controller
I am using the jQuery Form Plugin with my Rails app. I have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.