這是spring配置:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<!--開啟注解驅動-->
<mvc:annotation-driven />
<!--掃描包-->
<context:component-scan base-package="com.zyl.controller" />
<!--視圖決議器-->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="https://bbs.csdn.net/WEB-INF/jsp/" />
<property name="suffix" value="https://bbs.csdn.net/topics/.jsp" />
</bean>
</beans>
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
<!-- springmvc的前端控制器 -->
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
controller:

啟動tomcat能啟動成功

但是一訪問controller:直接404 連方法都沒有執行(后臺沒有輸出資訊)

大佬們救命啊!!!
uj5u.com熱心網友回復:
<url-pattern>/</url-pattern>改成<url-pattern>/*</url-pattern>試試uj5u.com熱心網友回復:
缺少專案名稱
http://localhost:8080/專案名稱/test
uj5u.com熱心網友回復:
tomcat配置的直接是/ 而且能夠啟動成功應該是不差這個專案名的
uj5u.com熱心網友回復:
<url-pattern>/</url-pattern>改成<url-pattern>/*</url-pattern>試試
不得行呀
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/283717.html
標籤:Java EE
