Understanding SPRINGMVC Paths

Asked 2 years ago, Updated 2 years ago, 84 views

I'm making my own SPRINGMVC system.The server starts, but when I type the path, the screen does not appear.I'm sorry, but I look forward to hearing from you.
Eclipse 4.6
STS 3.8
Tomcat8
Spring 4.3.2

WEB.XML

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns="http://xmlns.jcp.org/xml/ns/javaee"xmlns:jsp="http://java.sun.com/xml/ns/javaee/jsp"
 xsi: schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
 version="3.1" >
 <filter>
  <filter-name>CharacterEncodingFilter</filter-name>
  <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
  <init-param>
   <param-name>encoding</param-name>
   <param-value>utf-8</param-value>
  </init-param>
  <init-param>
   <param-name>forceEncoding</param-name>
   <param-value>true</param-value>
  </init-param>
 </filter>
 <filter-mapping>
  <filter-name>CharacterEncodingFilter</filter-name>
  <url-pattern>/*</url-pattern>
 </filter-mapping>
 <servlet>
  <servlet-name>dispatcher</servlet-name>
  <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  <init-param>
   <param-name>contextConfigLocation</param-name>
   <param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
  </init-param>
 </servlet>
 <servlet-mapping>
  <servlet-name>dispatcher</servlet-name>
  <url-pattern> /<url-pattern>
 </servlet-mapping>
 <jsp-config>
  <jsp-property-group>
   <url-pattern>*.jsp</url-pattern>
   <el-ignored> false</el-ignored>
   <page-encoding>utf-8</page-encoding>
   <scripting-invalid>true</scripting-invalid>
   <include-prelude>/WEB-INF/views/index.jsp</include-prelude>
  </jsp-property-group>
 </jsp-config>
</web-app>

JSP Location
webapp/WEB-INF/views/index.jsp

I have tried various paths.
localhost:18080/SpringMVC
localhost:18080/SpringMVC/index.jsp

java spring java8

2022-09-30 17:04

1 Answers

Files under WEB-INF cannot be viewed directly from the client (browser).

If you want the JSP file to be viewed directly (without creating a controller), you must place it outside the web-INF.

Place it in webapp/index.jsp and you will be able to see it in the path described in the question.


2022-09-30 17:04

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.