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;








1















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?










share|improve this question



















  • 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


















1















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?










share|improve this question



















  • 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














1












1








1








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?










share|improve this question














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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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 the StringToEnumConverterFactory. Prior to that you would have to write a custom converter/editor.

    – M. Deinum
    Mar 27 at 8:00













  • 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








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













1 Answer
1






active

oldest

votes


















1














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.






share|improve this answer
























    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
    );



    );













    draft saved

    draft discarded


















    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









    1














    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.






    share|improve this answer





























      1














      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.






      share|improve this answer



























        1












        1








        1







        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.






        share|improve this answer













        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.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        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



















            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.



















            draft saved

            draft discarded
















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

            155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해