• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Spring MVC - frustrated 404 error

 
Ranch Hand
Posts: 472
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good day,

I trying to access to http://localhost:8080/control/greeting.html, but it return me 404 error, no problem when access to http://localhost:8080/control/ , which return me and display index.jsp file. i can also access to http://localhost:8080/control/hello.jsp , which return me blank page with title name, but the bean value "hellospring" doesn't render.

the project setup using spring boot, i got the same error when i replace WebInitializer with web.xml file. I did remove the web.xml when apply WebInitializer java file.

below are the structure, appreciated your guidance !

[Project setup]


src\main\java\com\mvc\WebInitializer file :



src\main\java\com\mvc\Webconfig file :



src\main\java\com\mvc\controller\HelloController.java



Web,xml



src\main\webapp\Hello.jsp




pom.xml

project_structure.PNG
[Thumbnail for project_structure.PNG]
Project Structure
 
Ranch Hand
Posts: 58
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there,

Have you added some debugging statements to see if your controller method is being called?

My guess is that it's a problem with the view name you're supplying. I believe the default ViewResolver is a InternalResourceViewResolver. I think you therefore want to be returning a view name of "hello", rather than "hello.jsp".
 
Nakata kokuyo
Ranch Hand
Posts: 472
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Gordy, i did changed that before, it doesn't help in my case.
 
Nakata kokuyo
Ranch Hand
Posts: 472
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I try print out from the controller method, it doesn't show anything too, the controller method doesn't seem calling
 
Ranch Hand
Posts: 672
4
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Change the Request Mapping in the controller, i.e @RequestMapping(value="/greeting") to @RequestMapping(value="/greeting.html").
 
Nakata kokuyo
Ranch Hand
Posts: 472
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Prasad, i tried but still no luck yet
 
Prasad Krishnegowda
Ranch Hand
Posts: 672
4
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you show us your log file, with DEBUG enabled for spring classes.
 
Nakata kokuyo
Ranch Hand
Posts: 472
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Prasad, thanks for helping !

I got this resolved after change below in WebInitializer.java, i have no idea whether using setConfigLocation() need any extra IDE setting



to



 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Found similar article on this website, probably this will help, but its not in bootstrap

spring 4 mvc


Thanks
reply
    Bookmark Topic Watch Topic
  • New Topic