I'm Getting this error when I am accessing jsp file with springBoot in Eclipse
This error appear when i'm accessing the "http://localhost:8085/"
This localhost page can’t be foundNo webpage was found for the web address: http://localhost:8085/ HTTP ERROR 404
Here is HomeController file
package com.bhagya.app;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
@Controller
public class HomeController {
@GetMapping("/")
public String home() {
System.out.println("hello");
return "index"; // This corresponds to the "home.jsp" file in the "views" folder
}
}
Here is my CustomErrorController file
package com.bhagya.app;
import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class CustomErrorController implements ErrorController {
@GetMapping("/error")
public String handleError(Exception e) {
System.out.println("errorMessage ");
// Provide logic to handle errors and return a custom error page
return "error"; // This corresponds to the "error.jsp" file in the "views" folder
}
public String getErrorPath() {
return "/error";
}
}
I have written debug statament to print "error message" in CustomErrorController, the error message is printed but the issue is with return jsp file.
. ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ [32m :: Spring Boot :: [39m [2m (v3.2.2)[0;39m [2m2024-02-02T06:44:36.155+05:30[0;39m [32m INFO[0;39m [35m19404[0;39m [2m---[0;39m [2m[ main][0;39m [2m[0;39m[36mcom.bhagya.app.Web2Application [0;39m [2m:[0;39m Starting Web2Application using Java 17.0.9 with PID 19404 (C:\Users\bhagy\web-2\target\classes started by bhagy in C:\Users\bhagy\web-2) [2m2024-02-02T06:44:36.159+05:30[0;39m [32m INFO[0;39m [35m19404[0;39m [2m---[0;39m [2m[ main][0;39m [2m[0;39m[36mcom.bhagya.app.Web2Application [0;39m [2m:[0;39m No active profile set, falling back to 1 default profile: "default" [2m2024-02-02T06:44:37.270+05:30[0;39m [32m INFO[0;39m [35m19404[0;39m [2m---[0;39m [2m[ main][0;39m [2m[0;39m[36mo.s.b.w.embedded.tomcat.TomcatWebServer [0;39m [2m:[0;39m Tomcat initialized with port 8085 (http) [2m2024-02-02T06:44:37.284+05:30[0;39m [32m INFO[0;39m [35m19404[0;39m [2m---[0;39m [2m[ main][0;39m [2m[0;39m[36mo.apache.catalina.core.StandardService [0;39m [2m:[0;39m Starting service [Tomcat] [2m2024-02-02T06:44:37.285+05:30[0;39m [32m INFO[0;39m [35m19404[0;39m [2m---[0;39m [2m[ main][0;39m [2m[0;39m[36mo.apache.catalina.core.StandardEngine [0;39m [2m:[0;39m Starting Servlet engine: [Apache Tomcat/10.1.18] [2m2024-02-02T06:44:37.358+05:30[0;39m [32m INFO[0;39m [35m19404[0;39m [2m---[0;39m [2m[ main][0;39m [2m[0;39m[36mo.a.c.c.C.[Tomcat].[localhost].[/] [0;39m [2m:[0;39m Initializing Spring embedded WebApplicationContext [2m2024-02-02T06:44:37.359+05:30[0;39m [32m INFO[0;39m [35m19404[0;39m [2m---[0;39m [2m[ main][0;39m [2m[0;39m[36mw.s.c.ServletWebServerApplicationContext[0;39m [2m:[0;39m Root WebApplicationContext: initialization completed in 1141 ms [2m2024-02-02T06:44:37.770+05:30[0;39m [32m INFO[0;39m [35m19404[0;39m [2m---[0;39m [2m[ main][0;39m [2m[0;39m[36mo.s.b.w.embedded.tomcat.TomcatWebServer [0;39m [2m:[0;39m Tomcat started on port 8085 (http) with context path '' [2m2024-02-02T06:44:37.781+05:30[0;39m [32m INFO[0;39m [35m19404[0;39m [2m---[0;39m [2m[ main][0;39m [2m[0;39m[36mcom.bhagya.app.Web2Application [0;39m [2m:[0;39m Started Web2Application in 2.209 seconds (process running for 3.126) [2m2024-02-02T06:44:43.900+05:30[0;39m [32m INFO[0;39m [35m19404[0;39m [2m---[0;39m [2m[nio-8085-exec-1][0;39m [2m[0;39m[36mo.a.c.c.C.[Tomcat].[localhost].[/] [0;39m [2m:[0;39m Initializing Spring DispatcherServlet 'dispatcherServlet' [2m2024-02-02T06:44:43.900+05:30[0;39m [32m INFO[0;39m [35m19404[0;39m [2m---[0;39m [2m[nio-8085-exec-1][0;39m [2m[0;39m[36mo.s.web.servlet.DispatcherServlet [0;39m [2m:[0;39m Initializing Servlet 'dispatcherServlet' [2m2024-02-02T06:44:43.902+05:30[0;39m [32m INFO[0;39m [35m19404[0;39m [2m---[0;39m [2m[nio-8085-exec-1][0;39m [2m[0;39m[36mo.s.web.servlet.DispatcherServlet [0;39m [2m:[0;39m Completed initialization in 2 ms errorMessage errorMessage