相关疑难解决方法(0)

Spring Framework中applicationContext.xml和spring-servlet.xml之间的区别

  • applicationContext.xmlspring-servlet.xml在Spring框架无论如何有关系吗?
  • 声明的属性文件applicationContext.xml是否可用DispatcherServlet
  • 在相关的说明中,为什么我需要一个*-servlet.xml?为什么applicationContext.xml单独不足?

java spring

361
推荐指数
5
解决办法
17万
查看次数

无法阅读架构文档'http://www.springframework.org/schema/beans/spring-beans-3.0.xsd'

在启动我的Spring App时,我收到以下错误:

WARNING: Ignored XML validation warning
org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document     
'http://www.springframework.org/schema/beans/spring-beans-3.0.xsd', because
1) could not find the document;
2) the document could not be read;
3) the root element of the document is not <xsd:schema>.
Run Code Online (Sandbox Code Playgroud)

我的springapp-servlet.xml如下:

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"        
xmlns:aop="http://www.springframework.org/schema/aop"      
xsi:schemaLocation="http://www.springframework.org/schema/beans   
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean name="/hello.htm" class="springapp.web.HelloController"/>
</beans>
Run Code Online (Sandbox Code Playgroud)

请建议.

schema spring

14
推荐指数
1
解决办法
4万
查看次数

警告:在带有名称的DispatcherServlet中,找不到带有URI []的HTTP请求的映射

我有我的web.xml

<context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/applicationContext.xml</param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>2</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>dispatcher</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
Run Code Online (Sandbox Code Playgroud)

applicationContext as

<?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:p="http://www.springframework.org/schema/p"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd"
>

    <context:component-scan base-package="com.mindedges" />


</beans>
Run Code Online (Sandbox Code Playgroud)

Dispatcher servlet as

    <?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:p="http://www.springframework.org/schema/p"
           xmlns:aop="http://www.springframework.org/schema/aop"
           xmlns:tx="http://www.springframework.org/schema/tx"
           xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">

        <bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/>

        <!--
        Most controllers will use the ControllerClassNameHandlerMapping above, but
        for the index controller we are using ParameterizableViewController, so …
Run Code Online (Sandbox Code Playgroud)

java spring spring-mvc

4
推荐指数
1
解决办法
4万
查看次数

标签 统计

spring ×3

java ×2

schema ×1

spring-mvc ×1