I want to post ArrayList, but return null valueSpring Security OAuth2 SSO with Custom provider + logoutJakson polymorphic Enum caseError returned when trying to call my local webservice using springboot(Spring, Thymeleaf) How to request to controller 'POST' with list of model inside a model?MockMvc post junit test returning 415 when ResponseBody have collectionspringboot-mongodb CRUD applicationSpring boot security cannot log in after invalid credentialso.s.web.servlet.PageNotFound No mapping for GETSpring Controller gives me 404 status error@Value in Springboot returns null

Cubic programming and beyond?

Where is the USB2 OTG port on the RPi 4 Model B located?

Bishop game - python

How can one write good dialogue in a story without sounding wooden?

Why would guns not work in the dungeon?

I quit, and boss offered me 3 month "grace period" where I could still come back

Redirect https to fqdn

affect vs effect

Where or how can I find what interfaces an out of the box Apex class implements?

Why did my rum cake turn black?

Machine learning and operations research projects

Why do players in the past play much longer tournaments than today's top players?

Are there any intersection of Theory A and Theory B?

How might the United Kingdom become a republic?

What is temperature on a quantum level

Correct use of ergeben?

Creating custom objects with custom properties using generics

What is the difference between logical consistency and logical entailment in deductive logic?

(async () => )(); what is this?

Does Google Maps take into account hills/inclines for route times?

Is `curl something | sudo bash -` a reasonably safe installation method?

Why isn't there research to build a standard lunar, or Martian mobility platform?

Supporting developers who insist on using their pet language

Professor falsely accusing me of cheating in a class he does not teach, two months after end of the class. What precautions should I take?



I want to post ArrayList, but return null value


Spring Security OAuth2 SSO with Custom provider + logoutJakson polymorphic Enum caseError returned when trying to call my local webservice using springboot(Spring, Thymeleaf) How to request to controller 'POST' with list of model inside a model?MockMvc post junit test returning 415 when ResponseBody have collectionspringboot-mongodb CRUD applicationSpring boot security cannot log in after invalid credentialso.s.web.servlet.PageNotFound No mapping for GETSpring Controller gives me 404 status error@Value in Springboot returns null






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















POSTMAN :




"childDTO":[
"age":"80",
"gender":"kavi",
"occupation":"main",
"type":"mainlife"
,
"age":"80",
"gender":"kavi",
"occupation":"main",
"type":"mainlife"

]



Controller.....



@PostMapping("/child")
public List<CustomerDTO> childDTO(@RequestBody CustomerDTO cus)

return calculationService.childDTO(cus.getAge(),cus.getGender(),cus.getOccupation(),cus.getType());



Service......



public List<CustomerDTO> childDTO(String age, String gender, String occupation, String type);


Service Impl......



@Override



public List<CustomerDTO> childDTO(String age, String gender, String occupation, String type) 

List<CustomerDTO> typeChild = new ArrayList<>();
if (type==children)
for (CustomerDTO customer1 : typeChild)
customer1.setAge(age);
customer1.setGender(gender);
customer1.setOccupation(occupation);
customer1.setType(type);
customer1.setBenifits(benifitDTO(beni.getRiders(), beni.getSumAssuarance()));
System.out.println("list:-"+customer1);
typeChild.add(customer1);



System.out.println("list:-"+typeChild);
return typeChild;










share|improve this question
























  • Can you please post code of CustomerDTO ? and What value children will have!

    – user3145373 ツ
    Mar 26 at 5:19











  • private String age; private String gender; private String occupation; private String type; private BenifitsDTO benifits;

    – kaveeth sri
    Mar 26 at 5:33











  • So I think you post request will never be received as You're passing array data and in @RequestBody you're trying to receive data in single object !

    – user3145373 ツ
    Mar 26 at 5:36











  • controller :-CustomerDTO [age=null, gender=null, occupation=null, type=null, benifits=null]

    – kaveeth sri
    Mar 26 at 5:39











  • post request data not assign in controller

    – kaveeth sri
    Mar 26 at 5:40

















0















POSTMAN :




"childDTO":[
"age":"80",
"gender":"kavi",
"occupation":"main",
"type":"mainlife"
,
"age":"80",
"gender":"kavi",
"occupation":"main",
"type":"mainlife"

]



Controller.....



@PostMapping("/child")
public List<CustomerDTO> childDTO(@RequestBody CustomerDTO cus)

return calculationService.childDTO(cus.getAge(),cus.getGender(),cus.getOccupation(),cus.getType());



Service......



public List<CustomerDTO> childDTO(String age, String gender, String occupation, String type);


Service Impl......



@Override



public List<CustomerDTO> childDTO(String age, String gender, String occupation, String type) 

List<CustomerDTO> typeChild = new ArrayList<>();
if (type==children)
for (CustomerDTO customer1 : typeChild)
customer1.setAge(age);
customer1.setGender(gender);
customer1.setOccupation(occupation);
customer1.setType(type);
customer1.setBenifits(benifitDTO(beni.getRiders(), beni.getSumAssuarance()));
System.out.println("list:-"+customer1);
typeChild.add(customer1);



System.out.println("list:-"+typeChild);
return typeChild;










share|improve this question
























  • Can you please post code of CustomerDTO ? and What value children will have!

    – user3145373 ツ
    Mar 26 at 5:19











  • private String age; private String gender; private String occupation; private String type; private BenifitsDTO benifits;

    – kaveeth sri
    Mar 26 at 5:33











  • So I think you post request will never be received as You're passing array data and in @RequestBody you're trying to receive data in single object !

    – user3145373 ツ
    Mar 26 at 5:36











  • controller :-CustomerDTO [age=null, gender=null, occupation=null, type=null, benifits=null]

    – kaveeth sri
    Mar 26 at 5:39











  • post request data not assign in controller

    – kaveeth sri
    Mar 26 at 5:40













0












0








0








POSTMAN :




"childDTO":[
"age":"80",
"gender":"kavi",
"occupation":"main",
"type":"mainlife"
,
"age":"80",
"gender":"kavi",
"occupation":"main",
"type":"mainlife"

]



Controller.....



@PostMapping("/child")
public List<CustomerDTO> childDTO(@RequestBody CustomerDTO cus)

return calculationService.childDTO(cus.getAge(),cus.getGender(),cus.getOccupation(),cus.getType());



Service......



public List<CustomerDTO> childDTO(String age, String gender, String occupation, String type);


Service Impl......



@Override



public List<CustomerDTO> childDTO(String age, String gender, String occupation, String type) 

List<CustomerDTO> typeChild = new ArrayList<>();
if (type==children)
for (CustomerDTO customer1 : typeChild)
customer1.setAge(age);
customer1.setGender(gender);
customer1.setOccupation(occupation);
customer1.setType(type);
customer1.setBenifits(benifitDTO(beni.getRiders(), beni.getSumAssuarance()));
System.out.println("list:-"+customer1);
typeChild.add(customer1);



System.out.println("list:-"+typeChild);
return typeChild;










share|improve this question
















POSTMAN :




"childDTO":[
"age":"80",
"gender":"kavi",
"occupation":"main",
"type":"mainlife"
,
"age":"80",
"gender":"kavi",
"occupation":"main",
"type":"mainlife"

]



Controller.....



@PostMapping("/child")
public List<CustomerDTO> childDTO(@RequestBody CustomerDTO cus)

return calculationService.childDTO(cus.getAge(),cus.getGender(),cus.getOccupation(),cus.getType());



Service......



public List<CustomerDTO> childDTO(String age, String gender, String occupation, String type);


Service Impl......



@Override



public List<CustomerDTO> childDTO(String age, String gender, String occupation, String type) 

List<CustomerDTO> typeChild = new ArrayList<>();
if (type==children)
for (CustomerDTO customer1 : typeChild)
customer1.setAge(age);
customer1.setGender(gender);
customer1.setOccupation(occupation);
customer1.setType(type);
customer1.setBenifits(benifitDTO(beni.getRiders(), beni.getSumAssuarance()));
System.out.println("list:-"+customer1);
typeChild.add(customer1);



System.out.println("list:-"+typeChild);
return typeChild;







spring-boot






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 26 at 5:14









georges van

2,4632 gold badges25 silver badges40 bronze badges




2,4632 gold badges25 silver badges40 bronze badges










asked Mar 26 at 4:57









kaveeth srikaveeth sri

43 bronze badges




43 bronze badges












  • Can you please post code of CustomerDTO ? and What value children will have!

    – user3145373 ツ
    Mar 26 at 5:19











  • private String age; private String gender; private String occupation; private String type; private BenifitsDTO benifits;

    – kaveeth sri
    Mar 26 at 5:33











  • So I think you post request will never be received as You're passing array data and in @RequestBody you're trying to receive data in single object !

    – user3145373 ツ
    Mar 26 at 5:36











  • controller :-CustomerDTO [age=null, gender=null, occupation=null, type=null, benifits=null]

    – kaveeth sri
    Mar 26 at 5:39











  • post request data not assign in controller

    – kaveeth sri
    Mar 26 at 5:40

















  • Can you please post code of CustomerDTO ? and What value children will have!

    – user3145373 ツ
    Mar 26 at 5:19











  • private String age; private String gender; private String occupation; private String type; private BenifitsDTO benifits;

    – kaveeth sri
    Mar 26 at 5:33











  • So I think you post request will never be received as You're passing array data and in @RequestBody you're trying to receive data in single object !

    – user3145373 ツ
    Mar 26 at 5:36











  • controller :-CustomerDTO [age=null, gender=null, occupation=null, type=null, benifits=null]

    – kaveeth sri
    Mar 26 at 5:39











  • post request data not assign in controller

    – kaveeth sri
    Mar 26 at 5:40
















Can you please post code of CustomerDTO ? and What value children will have!

– user3145373 ツ
Mar 26 at 5:19





Can you please post code of CustomerDTO ? and What value children will have!

– user3145373 ツ
Mar 26 at 5:19













private String age; private String gender; private String occupation; private String type; private BenifitsDTO benifits;

– kaveeth sri
Mar 26 at 5:33





private String age; private String gender; private String occupation; private String type; private BenifitsDTO benifits;

– kaveeth sri
Mar 26 at 5:33













So I think you post request will never be received as You're passing array data and in @RequestBody you're trying to receive data in single object !

– user3145373 ツ
Mar 26 at 5:36





So I think you post request will never be received as You're passing array data and in @RequestBody you're trying to receive data in single object !

– user3145373 ツ
Mar 26 at 5:36













controller :-CustomerDTO [age=null, gender=null, occupation=null, type=null, benifits=null]

– kaveeth sri
Mar 26 at 5:39





controller :-CustomerDTO [age=null, gender=null, occupation=null, type=null, benifits=null]

– kaveeth sri
Mar 26 at 5:39













post request data not assign in controller

– kaveeth sri
Mar 26 at 5:40





post request data not assign in controller

– kaveeth sri
Mar 26 at 5:40












2 Answers
2






active

oldest

votes


















1














You did not post what variable children is, probably some class field, but you cannot compare Java Strings with ==. Java Strings must be compared with .equals:



...
if (type.equals(children)) {
...


Use a debugger next time, to see what's happening in your code.






share|improve this answer






























    0














    Your request and controller RequestBody structure do not match.
    You need to use List.



    @PostMapping("/child")
    public List<CustomerDTO> childDTO(@RequestBody List<CustomerDTO> cusList) // here list needs to be used
    if(cusList != null && !cusList.isEmpty())
    CustomerDTO cus = cusList.get(0); // it will get first element from the list, if you want to process all the elements then you need to iterate the list
    return calculationService.childDTO(cus.getAge(),cus.getGender(),cus.getOccupation(),cus.getType());




    Now other logic will be as it or you may change it as per your requirement.






    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%2f55350100%2fi-want-to-post-arraylist-but-return-null-value%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      You did not post what variable children is, probably some class field, but you cannot compare Java Strings with ==. Java Strings must be compared with .equals:



      ...
      if (type.equals(children)) {
      ...


      Use a debugger next time, to see what's happening in your code.






      share|improve this answer



























        1














        You did not post what variable children is, probably some class field, but you cannot compare Java Strings with ==. Java Strings must be compared with .equals:



        ...
        if (type.equals(children)) {
        ...


        Use a debugger next time, to see what's happening in your code.






        share|improve this answer

























          1












          1








          1







          You did not post what variable children is, probably some class field, but you cannot compare Java Strings with ==. Java Strings must be compared with .equals:



          ...
          if (type.equals(children)) {
          ...


          Use a debugger next time, to see what's happening in your code.






          share|improve this answer













          You did not post what variable children is, probably some class field, but you cannot compare Java Strings with ==. Java Strings must be compared with .equals:



          ...
          if (type.equals(children)) {
          ...


          Use a debugger next time, to see what's happening in your code.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 26 at 5:14









          StrelokStrelok

          40k6 gold badges80 silver badges103 bronze badges




          40k6 gold badges80 silver badges103 bronze badges























              0














              Your request and controller RequestBody structure do not match.
              You need to use List.



              @PostMapping("/child")
              public List<CustomerDTO> childDTO(@RequestBody List<CustomerDTO> cusList) // here list needs to be used
              if(cusList != null && !cusList.isEmpty())
              CustomerDTO cus = cusList.get(0); // it will get first element from the list, if you want to process all the elements then you need to iterate the list
              return calculationService.childDTO(cus.getAge(),cus.getGender(),cus.getOccupation(),cus.getType());




              Now other logic will be as it or you may change it as per your requirement.






              share|improve this answer



























                0














                Your request and controller RequestBody structure do not match.
                You need to use List.



                @PostMapping("/child")
                public List<CustomerDTO> childDTO(@RequestBody List<CustomerDTO> cusList) // here list needs to be used
                if(cusList != null && !cusList.isEmpty())
                CustomerDTO cus = cusList.get(0); // it will get first element from the list, if you want to process all the elements then you need to iterate the list
                return calculationService.childDTO(cus.getAge(),cus.getGender(),cus.getOccupation(),cus.getType());




                Now other logic will be as it or you may change it as per your requirement.






                share|improve this answer

























                  0












                  0








                  0







                  Your request and controller RequestBody structure do not match.
                  You need to use List.



                  @PostMapping("/child")
                  public List<CustomerDTO> childDTO(@RequestBody List<CustomerDTO> cusList) // here list needs to be used
                  if(cusList != null && !cusList.isEmpty())
                  CustomerDTO cus = cusList.get(0); // it will get first element from the list, if you want to process all the elements then you need to iterate the list
                  return calculationService.childDTO(cus.getAge(),cus.getGender(),cus.getOccupation(),cus.getType());




                  Now other logic will be as it or you may change it as per your requirement.






                  share|improve this answer













                  Your request and controller RequestBody structure do not match.
                  You need to use List.



                  @PostMapping("/child")
                  public List<CustomerDTO> childDTO(@RequestBody List<CustomerDTO> cusList) // here list needs to be used
                  if(cusList != null && !cusList.isEmpty())
                  CustomerDTO cus = cusList.get(0); // it will get first element from the list, if you want to process all the elements then you need to iterate the list
                  return calculationService.childDTO(cus.getAge(),cus.getGender(),cus.getOccupation(),cus.getType());




                  Now other logic will be as it or you may change it as per your requirement.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 26 at 5:46









                  user3145373 ツuser3145373 ツ

                  5,0535 gold badges29 silver badges49 bronze badges




                  5,0535 gold badges29 silver badges49 bronze badges



























                      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%2f55350100%2fi-want-to-post-arraylist-but-return-null-value%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

                      Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                      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

                      은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현