全部 我正在开发一个简单的登录项目,并试图让该应用程序在 tomcat 服务器中运行,我也遇到了“无法更改项目方面动态 web 模块版本错误”的几个问题。试图通过更改来解决它模块的版本并确保适当的 java jee 也存在。但失败了。现在有这个服务器上下文初始化失败错误。还有。有人可以帮助我吗? 提前致谢
SampleLoginApp-servlet.xml:
enter code here
<?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: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-4.3.xsd">
<context:component-scan base-package="com.sample.Controller"></context:component-scan>
<mvc:annotation-driven></mvc:annotation-driven>
<bean id="jspviewresolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsps/"></property>
<property name="suffix" value=".html"></property>
</bean>
</beans>
网络.xml
在此输入验证码
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>SampleLoginApp</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<description></description>
<display-name>SampleLoginApp</display-name>
<servlet-name>SampleLoginApp</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>SampleLoginApp</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
最佳答案
在您的 SampleLoginApp-servlet.xml
中,您声明了 xmlns:mvc="http://www.springframework.org/schema/mvc"
我没有看到为它定义了 xsi:schemaLocation
。您可以尝试添加以下行吗
"http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd"
关于java - 匹配的通配符是严格的,但找不到元素 'mvc:annotation-driven' 的声明。标准包装器.Throwable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47025813/