• Post Reply Bookmark Topic Watch Topic
  • New Topic

Spring MVC - frustrated 404 error  RSS feed

 
Nakata kokuyo
Ranch Hand
Posts: 472
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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
 
Gordon Brown
Ranch Hand
Posts: 58
2
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
 
Prasad Krishnegowda
Ranch Hand
Posts: 672
4
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thanks Prasad, i tried but still no luck yet
 
Prasad Krishnegowda
Ranch Hand
Posts: 672
4
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • 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
  • 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



 
Yashwant Chavan
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Found similar article on this website, probably this will help, but its not in bootstrap

spring 4 mvc


Thanks
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!