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 7897737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:14:38+00:00 2026-06-03T08:14:38+00:00

I have this form with the parameter year and name : /register?year=&name=test My class

  • 0

I have this form with the parameter year and name:

/register?year=&name=test

My class looks like this:

public class Organizer {
   private String name;
   private int year;

My controller maps those two parameters to my class Organizer

@RequestMapping("/register")
public String register(@Valid Organizer organizer, BindingResult errors...

The problem is binding the parameter year to int. Spring gives me the error

Failed to convert property value of type ‘java.lang.String’ to required type ‘int’ for property ‘year’; nested exception is java.lang.IllegalArgumentException:

I figured out how to add my own custom property editor, but getValue() never seems to be called

@InitBinder
public void binder(WebDataBinder binder) {
    binder.registerCustomEditor(int.class, new CustomIntEditor());
}

public class CustomIntEditor extends PropertyEditorSupport {

I thought I would be able to return the int value 0 when the year parameter was anything other than an int value (Integer.parseInt() -> catch exception)

@Override
public void setAsText(String text) throws IllegalArgumentException {

    //Some parsing and error handling
    setValue((int)0);
}

I would like to be able to:

  • Set the field year to int value 0

  • Create a custom error message : organizer.year.invalid

  • 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-03T08:14:40+00:00Added an answer on June 3, 2026 at 8:14 am

    Change int to Integer. This is an auto-boxing issue. Since year is empty, it can’t be converted to a primitive value (as you have not specified a default value).

    Then you can annotate it @NotNull to get the validation you want.

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

Sidebar

Related Questions

I have the following form. <form id=langForm action= method=get> <select name=lang id=lang class=styled onchange=this.form.submit();>
I currently have something like this: <form action=cart.php?action=update method=post name=cart id=cart> <input maxlength=3 value=25
I have this form:- <form action=> <table border=0> <td colspan=2 class=instruction>Select your desired option
I have this form: <form action=contact.php method=post id=contactform> <ol> <li> <label for=name>First Name *
In Kohana/CodeIgniter, I can have a URL in this form: http://www.name.tld/controller_name/method_name/parameter_1/parameter_2/parameter_3 ... And then
I have a web service I'm trying to hit, URL looks like this: http://servername/webapp/ws/invoices/{invoiceid}
I have this form. Basically what I want is to send a auto-response with
I have this form submit code: Event.observe(window, 'load', init, false); function init() { Event.observe('addressForm',
I have this form for inputting the birthday in html. But I only have
I have this form: <input type=checkbox value=First />First <input type=checkbox value=Second />Second <input type=checkbox

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.