有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

JavaSpring3拦截器错误:类型元素类型“bean”后面必须跟属性规范“>”或“/>”

我是Spring 3 MVC的新手,尝试通过以下URL作为参考,在示例中实现Interceptors

http://viralpatel.net/blogs/spring-mvc-interceptor-example/

我在spring 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:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/mvc 
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context 
http://www.springframework.org/schema/context/spring-context-3.0.xsd"> 
<context:annotation-config />
<context:component-scan
    base-package="com.spring.controller" />

<mvc:interceptors>
  <bean class="com.spring.interceptor.HelloWorldInterceptor" />
</mvc:interceptors>    
     <bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsp/" />

我在这一行中发现了这个错误:

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 

请让我知道如何解决这个问题


共 (2) 个答案

  1. # 2 楼答案

    请关闭你的bean定义

      <bean id="jspViewResolver" 
      class="org.springframework.web.servlet.view.InternalResourceViewResolver"/>