• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

Cannot convert value of type 'com.mart.application.model.Login' to required type 'java.lang.String':

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I am trying to start a session after login. If not successfull then it will throw flash message.
Everything is fine incase of invalid login.
But successfull login throws error:
Cannot convert value of type 'com.mart.application.model.Login' to required type 'java.lang.String': no matching editors or conversion strategy found

I tried by sending text as session value hard coding. This time page loads but without session variable.
Can you please help me. I'm trying to shift from php to Java
 
Bartender
Posts: 2264
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess the correct way to use ModelAndView is:
ModelAndView mav = new ModelAndView();
mav.addObject(...)
mav.setViewName("login")
return mav;

Examples can be found here  https://zetcode.com/springboot/model/ ,
https://github.com/eugenp/tutorials/blob/master/spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/controller/controller/PassParametersController.java
https://www.baeldung.com/spring-mvc-model-model-map-model-view
reply
    Bookmark Topic Watch Topic
  • New Topic