SpringBoot Controller returns a 404 error as a result of the JSP page

Micro wx smile

  • Apache
  • spring
  • tomcat
  • The container
  • springboot
  • string
  • 404
  • xml
  • scope
  • Servlet
  • JSP
  • view
  • Controller

Spring Boot Controller returns a 404 error. Spring Boot Controller returns a 404 error @Controller public class LoginBackController { public Login…

Spring Boot Controller returns a 404 error. Spring Boot Controller returns a 404 error

Such as:

@Controller public class LoginBackController { public LoginBackController() { // TODO Auto-generated constructor stub } @RequestMapping("/loginback") public String index(Map<String,Object> map){ map.put("name", "HelloController"); return "loginback"; }}Copy the code

In return “loginback”; A one-line breakpoint can be hit,

But a browser visit returns a 404 error.

This is due to the lack of dependencies,

Add the following dependencies to pom.xml:

Pom.xml adds a dependency to support JSP

<! Javax. servlet</groupId> <artifactId>javax.servlet-api</artifactId> <scope>provided</scope> </dependency> <! JSTL (JSP Standard TagLibrary) is an evolving open source JSP TagLibrary maintained by apache's Jakarta team. JSTL can only run on containers that support the JSP1.2 and Servlet2.3 specifications, such as tomcat 4.x. It is also supported as a standard in JSP2.0. Otherwise the exception information: javax.mail. Servlet. ServletException: Circular view path [/ helloJsp] : would dispatch back to the current handler URL[/helloJsp] again. Check your ViewResolver setup! (Hint: This may be the resultof an unspecified view, due to default view name generation.) --> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> </dependency> <! -- Provided --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-jasper</artifactId> <scope>provided</scope> </dependency>Copy the code

Use the cloud habitat community APP, comfortable ~

For details, please click
Comments (0)

To:


Related articles

  • Spring&Vue single page development with front and back end separation (2)
  • Springboot Learning – Build the first Springboot…
  • Unified handling of JavaWeb exception Messages (using Springmv…
  • SpringBoot @ RestController no…
  • SpringBoot development case of clever technology
  • SpringBoot is that simple
  • For SpringMVC from SpringBoot
  • Whitelabel Error Page feature
  • SpringBoot Self-study Notes (a)
  • SpringBoot integrated JSP (with source code) + encountered pits

The net friend comment on