WebSphere:无法为元素[default-servlet-handler]找到BeanDefinitionParser

时间:2017-08-02 15:14:03

标签: java spring spring-mvc

您好我是rad和websphere的新手,我最近遇到了这个问题,所以我的问题很简单

  

MVC-调度员的servlet

我有两行我的项目所需的块,它们是:

  

mvc:annotation-driven enableMatrixVariables =" true"   MVC:默认servlet的处理程序

当我运行我的项目时,它给了我这个错误

  

配置问题:找不到元素[default-servlet-handler]的BeanDefinitionParser

这些是我的文件:

的web.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/web-app_2_5.xsd" 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
version="2.5">
<display-name>Spring MVC Application</display-name>

<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>

<servlet>
<servlet-name>mvc-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-
class>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>mvc-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
 <listener>
  <listener-
  class>org.springframework.web.context.ContextLoaderListener</listener-
  class>
  </listener>
   <context-param>
  <param-name>contextConfigLocation</param-name>
<param-value>
        /WEB-INF/mvc-dispatcher-servlet.xml,
        /WEB-INF/spring-security.xml
    </param-value>
  </context-param>
  <filter>
   <filter-name>springSecurityFilterChain</filter-name>
   <filter-
class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>springSecurityFilterChain</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
</web-app>

MVC-调度-servlet.xml中

<?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/mvc 
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
    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-3.2.xsd">

<context:component-scan base-package="com.cnrd.cdm.controller" />
<context:component-scan base-package="com.cnrd.cdm.business" />
<context:component-scan base-package="com.cnrd.cdm.dao" />
<context:component-scan base-package="com.cnrd.cdm.models" />


<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="com.ibm.db2.jcc.DB2Driver" />
    <property name="url" value="jdbc:db2://<hostip>:port/DB2MPREP" />
    <property name="username" value="user"/>
    <property name="password" value="******"/>
</bean>

<bean class="org.springframework.jdbc.core.JdbcTemplate">
    <property name="dataSource" ref="dataSource"></property>
</bean> 

<!-- <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="com.mysql.jdbc.Driver" />
    <property name="url" value="jdbc:mysql://localhost/mdb40" />
    <property name="username" value="root"/>
    <property name="password" value=""/>
</bean>

<bean class="org.springframework.jdbc.core.JdbcTemplate">
    <property name="dataSource" ref="dataSource"></property>
</bean>
 -->
<bean
    class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix">
        <value>/WEB-INF/views</value>
    </property>
    <property name="suffix">
        <value>.jsp</value>
    </property>
</bean>

<mvc:annotation-driven enableMatrixVariables="true"/>
<mvc:default-servlet-handler/>

<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver" />

注意:我的libs文件夹中包含 spring-webmvc-3.2.8.RELEASE.jar 。 注2:具有相同库和文件的相同项目在eclipse上正常工作。

提前感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

这是一个Maven项目吗?如果是,请尝试mvn clean package -U。如果这不起作用,请选择Maven - &gt;更新项目。如果这两个不起作用,请发布您的pom.xml文件。