Spring boot able to accept Enum as Request parameterHow to configure port for a Spring Boot applicationenum to string in modern C++11 / C++14 / C++17 and future C++20Spring Boot REST service exception handlingSpring Boot: Inject a custom context pathSpring Boot application.propertiesWhat does spring-boot-starter-parent exactly do in pom file?Difference between spring-data-jpa and spring-boot-starter-data-jpaEnum translation in Spring Data REST repositoriesSpring Boot MVC application JSP not displayingSpring vs Spring boot reverse proxy troubles
What is the idiomatic way of saying “he is ticklish under armpits”?
What does Apple mean by "This may decrease battery life"?
Dropdowns & Chevrons for Right to Left languages
Was the 2019 Lion King film made through motion capture?
Shabbat clothing on shabbat chazon
Can an SPI slave start a transmission in full-duplex mode?
Can I call myself an assistant professor without a PhD?
Why are the inside diameters of some pipe larger than the stated size?
Look mom! I made my own (Base 10) numeral system!
Infeasibility in mathematical optimization models
What are the uses and limitations of Persuasion, Insight, and Deception against other PCs?
Dereferencing a pointer in a 'for' loop initializer creates a segmentation fault
Can we tile the board by L trominos?
How does The Fools Guild make its money?
As a 16 year old, how can I keep my money safe from my mother?
Was this a rapid SCHEDULED disassembly? How was it done?
Max Order of an Isogeny Class of Rational Elliptic Curves is 8?
How many hit points does the Battle Smith Artificer's Iron Defender have?
Team goes to lunch frequently, I do intermittent fasting but still want to socialize
Drawing complex inscribed and circumscribed polygons in TikZ
Visa National - No Exit Stamp From France on Return to the UK
Converting Piecewise function to C code
I was asked to prove the Principle of Cauchy Induction
Senior dev discreetly remoting in to computer and watching a coworker
Spring boot able to accept Enum as Request parameter
How to configure port for a Spring Boot applicationenum to string in modern C++11 / C++14 / C++17 and future C++20Spring Boot REST service exception handlingSpring Boot: Inject a custom context pathSpring Boot application.propertiesWhat does spring-boot-starter-parent exactly do in pom file?Difference between spring-data-jpa and spring-boot-starter-data-jpaEnum translation in Spring Data REST repositoriesSpring Boot MVC application JSP not displayingSpring vs Spring boot reverse proxy troubles
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
So, I got into this new Spring Boot project which was already under developement and while writing API's I used Enum for @RequestParam in my controller and it worked.
I did not write any converters for this.
Later on I noticed that in this project the other developers had written custom Converter's for this.
So I decided to search the web regarding this and all solutions that came up for using Enum with Controller in Spring Boot used converter, could not find any examples without converter like how I did.
Below is one an example of how I wrote this, LoanStatus is an Enum:
@RequestMapping(value = "/loans", method = RequestMethod.GET)
public ResponseEntity<?> getPatientsLoan(HttpServletRequest request,
@RequestParam(value = "loanStatus", required = false) LoanStatus loanStatus)
So is this a relatively new feature that Spring Boot accepts Enums now without the need for converter's and that is why all the examples used converters or will I face some issue in feature cause I did not user converter's even though it is currently working for me?
java spring spring-boot enums
add a comment |
So, I got into this new Spring Boot project which was already under developement and while writing API's I used Enum for @RequestParam in my controller and it worked.
I did not write any converters for this.
Later on I noticed that in this project the other developers had written custom Converter's for this.
So I decided to search the web regarding this and all solutions that came up for using Enum with Controller in Spring Boot used converter, could not find any examples without converter like how I did.
Below is one an example of how I wrote this, LoanStatus is an Enum:
@RequestMapping(value = "/loans", method = RequestMethod.GET)
public ResponseEntity<?> getPatientsLoan(HttpServletRequest request,
@RequestParam(value = "loanStatus", required = false) LoanStatus loanStatus)
So is this a relatively new feature that Spring Boot accepts Enums now without the need for converter's and that is why all the examples used converters or will I face some issue in feature cause I did not user converter's even though it is currently working for me?
java spring spring-boot enums
1
String to enum conversion has been possible since Spring 3 (and has nothing to do with Spring Boot!). See theStringToEnumConverterFactory. Prior to that you would have to write a custom converter/editor.
– M. Deinum
Mar 27 at 8:00
add a comment |
So, I got into this new Spring Boot project which was already under developement and while writing API's I used Enum for @RequestParam in my controller and it worked.
I did not write any converters for this.
Later on I noticed that in this project the other developers had written custom Converter's for this.
So I decided to search the web regarding this and all solutions that came up for using Enum with Controller in Spring Boot used converter, could not find any examples without converter like how I did.
Below is one an example of how I wrote this, LoanStatus is an Enum:
@RequestMapping(value = "/loans", method = RequestMethod.GET)
public ResponseEntity<?> getPatientsLoan(HttpServletRequest request,
@RequestParam(value = "loanStatus", required = false) LoanStatus loanStatus)
So is this a relatively new feature that Spring Boot accepts Enums now without the need for converter's and that is why all the examples used converters or will I face some issue in feature cause I did not user converter's even though it is currently working for me?
java spring spring-boot enums
So, I got into this new Spring Boot project which was already under developement and while writing API's I used Enum for @RequestParam in my controller and it worked.
I did not write any converters for this.
Later on I noticed that in this project the other developers had written custom Converter's for this.
So I decided to search the web regarding this and all solutions that came up for using Enum with Controller in Spring Boot used converter, could not find any examples without converter like how I did.
Below is one an example of how I wrote this, LoanStatus is an Enum:
@RequestMapping(value = "/loans", method = RequestMethod.GET)
public ResponseEntity<?> getPatientsLoan(HttpServletRequest request,
@RequestParam(value = "loanStatus", required = false) LoanStatus loanStatus)
So is this a relatively new feature that Spring Boot accepts Enums now without the need for converter's and that is why all the examples used converters or will I face some issue in feature cause I did not user converter's even though it is currently working for me?
java spring spring-boot enums
java spring spring-boot enums
asked Mar 27 at 7:46
ThanthuThanthu
1,1155 silver badges21 bronze badges
1,1155 silver badges21 bronze badges
1
String to enum conversion has been possible since Spring 3 (and has nothing to do with Spring Boot!). See theStringToEnumConverterFactory. Prior to that you would have to write a custom converter/editor.
– M. Deinum
Mar 27 at 8:00
add a comment |
1
String to enum conversion has been possible since Spring 3 (and has nothing to do with Spring Boot!). See theStringToEnumConverterFactory. Prior to that you would have to write a custom converter/editor.
– M. Deinum
Mar 27 at 8:00
1
1
String to enum conversion has been possible since Spring 3 (and has nothing to do with Spring Boot!). See the
StringToEnumConverterFactory. Prior to that you would have to write a custom converter/editor.– M. Deinum
Mar 27 at 8:00
String to enum conversion has been possible since Spring 3 (and has nothing to do with Spring Boot!). See the
StringToEnumConverterFactory. Prior to that you would have to write a custom converter/editor.– M. Deinum
Mar 27 at 8:00
add a comment |
1 Answer
1
active
oldest
votes
Spring has supported String to Enum conversion since Spring 3.0. There is a ConverterFactory which dynamically creates a converter for the specific enum.
Prior to that you would need to write a custom Converter or PropertyEditor to convert enums. But basicallly with the current versions you don't need to if the String matches the Enum name.
If you want custom enum conversion (by some internal value or whatever) you still would need a custom converter.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
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%2f55372117%2fspring-boot-able-to-accept-enum-as-request-parameter%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Spring has supported String to Enum conversion since Spring 3.0. There is a ConverterFactory which dynamically creates a converter for the specific enum.
Prior to that you would need to write a custom Converter or PropertyEditor to convert enums. But basicallly with the current versions you don't need to if the String matches the Enum name.
If you want custom enum conversion (by some internal value or whatever) you still would need a custom converter.
add a comment |
Spring has supported String to Enum conversion since Spring 3.0. There is a ConverterFactory which dynamically creates a converter for the specific enum.
Prior to that you would need to write a custom Converter or PropertyEditor to convert enums. But basicallly with the current versions you don't need to if the String matches the Enum name.
If you want custom enum conversion (by some internal value or whatever) you still would need a custom converter.
add a comment |
Spring has supported String to Enum conversion since Spring 3.0. There is a ConverterFactory which dynamically creates a converter for the specific enum.
Prior to that you would need to write a custom Converter or PropertyEditor to convert enums. But basicallly with the current versions you don't need to if the String matches the Enum name.
If you want custom enum conversion (by some internal value or whatever) you still would need a custom converter.
Spring has supported String to Enum conversion since Spring 3.0. There is a ConverterFactory which dynamically creates a converter for the specific enum.
Prior to that you would need to write a custom Converter or PropertyEditor to convert enums. But basicallly with the current versions you don't need to if the String matches the Enum name.
If you want custom enum conversion (by some internal value or whatever) you still would need a custom converter.
answered Mar 27 at 8:02
M. DeinumM. Deinum
75.7k16 gold badges151 silver badges159 bronze badges
75.7k16 gold badges151 silver badges159 bronze badges
add a comment |
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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%2f55372117%2fspring-boot-able-to-accept-enum-as-request-parameter%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
1
String to enum conversion has been possible since Spring 3 (and has nothing to do with Spring Boot!). See the
StringToEnumConverterFactory. Prior to that you would have to write a custom converter/editor.– M. Deinum
Mar 27 at 8:00