JavaScript: Formdata append null value - NumberFormatException
up vote
0
down vote
favorite
The following client code
FormData formData = FormData(document.getElementById(formElemId));
formData.append('version', null);
when received in Server Side via Spring MVC as below
@RequestParam(value = 'version', required = false) Integer versionNumber
throws the following exception
Failed to convert value of type 'java.lang.String' to required type 'java.lang.Integer'; nested exception is java.lang.NumberFormatException: For input string: "null"
javascript ajax spring-mvc form-data
add a comment |
up vote
0
down vote
favorite
The following client code
FormData formData = FormData(document.getElementById(formElemId));
formData.append('version', null);
when received in Server Side via Spring MVC as below
@RequestParam(value = 'version', required = false) Integer versionNumber
throws the following exception
Failed to convert value of type 'java.lang.String' to required type 'java.lang.Integer'; nested exception is java.lang.NumberFormatException: For input string: "null"
javascript ajax spring-mvc form-data
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
The following client code
FormData formData = FormData(document.getElementById(formElemId));
formData.append('version', null);
when received in Server Side via Spring MVC as below
@RequestParam(value = 'version', required = false) Integer versionNumber
throws the following exception
Failed to convert value of type 'java.lang.String' to required type 'java.lang.Integer'; nested exception is java.lang.NumberFormatException: For input string: "null"
javascript ajax spring-mvc form-data
The following client code
FormData formData = FormData(document.getElementById(formElemId));
formData.append('version', null);
when received in Server Side via Spring MVC as below
@RequestParam(value = 'version', required = false) Integer versionNumber
throws the following exception
Failed to convert value of type 'java.lang.String' to required type 'java.lang.Integer'; nested exception is java.lang.NumberFormatException: For input string: "null"
javascript ajax spring-mvc form-data
javascript ajax spring-mvc form-data
asked Nov 8 at 10:35
Mohan Krishnan
508
508
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
You can resolve this issue by adding defaultValue
like below.
@RequestParam(value = "version", required = false, defaultValue = "0") Integer versionNumber
see documentation
Unfortunately I cannot set a default value to the version (Application Logic). I'll have to handle the null in client itself. So I was wondering what turns my null object in client to string null when received in server.
– Mohan Krishnan
Nov 8 at 13:58
actually it was a bug in previous versions which has been resolved now...try with latest versions defaultValue is not needed.
– Alien
Nov 8 at 14:01
Oh thanks for that. Can you please let me know on which version is this bug was fixed. Am currently on 4.3.9
– Mohan Krishnan
Nov 8 at 14:08
1
This was considered a bug in 2013: jira.spring.io/browse/SPR-10180 and was fixed with version 3.2.2. Problem shouldn't occur in any versions after that and your code should work just fine.
– Alien
Nov 8 at 14:18
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
You can resolve this issue by adding defaultValue
like below.
@RequestParam(value = "version", required = false, defaultValue = "0") Integer versionNumber
see documentation
Unfortunately I cannot set a default value to the version (Application Logic). I'll have to handle the null in client itself. So I was wondering what turns my null object in client to string null when received in server.
– Mohan Krishnan
Nov 8 at 13:58
actually it was a bug in previous versions which has been resolved now...try with latest versions defaultValue is not needed.
– Alien
Nov 8 at 14:01
Oh thanks for that. Can you please let me know on which version is this bug was fixed. Am currently on 4.3.9
– Mohan Krishnan
Nov 8 at 14:08
1
This was considered a bug in 2013: jira.spring.io/browse/SPR-10180 and was fixed with version 3.2.2. Problem shouldn't occur in any versions after that and your code should work just fine.
– Alien
Nov 8 at 14:18
add a comment |
up vote
0
down vote
accepted
You can resolve this issue by adding defaultValue
like below.
@RequestParam(value = "version", required = false, defaultValue = "0") Integer versionNumber
see documentation
Unfortunately I cannot set a default value to the version (Application Logic). I'll have to handle the null in client itself. So I was wondering what turns my null object in client to string null when received in server.
– Mohan Krishnan
Nov 8 at 13:58
actually it was a bug in previous versions which has been resolved now...try with latest versions defaultValue is not needed.
– Alien
Nov 8 at 14:01
Oh thanks for that. Can you please let me know on which version is this bug was fixed. Am currently on 4.3.9
– Mohan Krishnan
Nov 8 at 14:08
1
This was considered a bug in 2013: jira.spring.io/browse/SPR-10180 and was fixed with version 3.2.2. Problem shouldn't occur in any versions after that and your code should work just fine.
– Alien
Nov 8 at 14:18
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
You can resolve this issue by adding defaultValue
like below.
@RequestParam(value = "version", required = false, defaultValue = "0") Integer versionNumber
see documentation
You can resolve this issue by adding defaultValue
like below.
@RequestParam(value = "version", required = false, defaultValue = "0") Integer versionNumber
see documentation
answered Nov 8 at 10:52
Alien
3,60621022
3,60621022
Unfortunately I cannot set a default value to the version (Application Logic). I'll have to handle the null in client itself. So I was wondering what turns my null object in client to string null when received in server.
– Mohan Krishnan
Nov 8 at 13:58
actually it was a bug in previous versions which has been resolved now...try with latest versions defaultValue is not needed.
– Alien
Nov 8 at 14:01
Oh thanks for that. Can you please let me know on which version is this bug was fixed. Am currently on 4.3.9
– Mohan Krishnan
Nov 8 at 14:08
1
This was considered a bug in 2013: jira.spring.io/browse/SPR-10180 and was fixed with version 3.2.2. Problem shouldn't occur in any versions after that and your code should work just fine.
– Alien
Nov 8 at 14:18
add a comment |
Unfortunately I cannot set a default value to the version (Application Logic). I'll have to handle the null in client itself. So I was wondering what turns my null object in client to string null when received in server.
– Mohan Krishnan
Nov 8 at 13:58
actually it was a bug in previous versions which has been resolved now...try with latest versions defaultValue is not needed.
– Alien
Nov 8 at 14:01
Oh thanks for that. Can you please let me know on which version is this bug was fixed. Am currently on 4.3.9
– Mohan Krishnan
Nov 8 at 14:08
1
This was considered a bug in 2013: jira.spring.io/browse/SPR-10180 and was fixed with version 3.2.2. Problem shouldn't occur in any versions after that and your code should work just fine.
– Alien
Nov 8 at 14:18
Unfortunately I cannot set a default value to the version (Application Logic). I'll have to handle the null in client itself. So I was wondering what turns my null object in client to string null when received in server.
– Mohan Krishnan
Nov 8 at 13:58
Unfortunately I cannot set a default value to the version (Application Logic). I'll have to handle the null in client itself. So I was wondering what turns my null object in client to string null when received in server.
– Mohan Krishnan
Nov 8 at 13:58
actually it was a bug in previous versions which has been resolved now...try with latest versions defaultValue is not needed.
– Alien
Nov 8 at 14:01
actually it was a bug in previous versions which has been resolved now...try with latest versions defaultValue is not needed.
– Alien
Nov 8 at 14:01
Oh thanks for that. Can you please let me know on which version is this bug was fixed. Am currently on 4.3.9
– Mohan Krishnan
Nov 8 at 14:08
Oh thanks for that. Can you please let me know on which version is this bug was fixed. Am currently on 4.3.9
– Mohan Krishnan
Nov 8 at 14:08
1
1
This was considered a bug in 2013: jira.spring.io/browse/SPR-10180 and was fixed with version 3.2.2. Problem shouldn't occur in any versions after that and your code should work just fine.
– Alien
Nov 8 at 14:18
This was considered a bug in 2013: jira.spring.io/browse/SPR-10180 and was fixed with version 3.2.2. Problem shouldn't occur in any versions after that and your code should work just fine.
– Alien
Nov 8 at 14:18
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53205938%2fjavascript-formdata-append-null-value-numberformatexception%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown