配置struts2 web.xml 报错

我在配置自己第一个struts2的时候,是在myeclipse8.6中创建了一个新的Web Project,然后WebRoot/WEB-INF下的web.xml是自动生成的,xml头文件信息为:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns
="http://java.sun.com/xml/ns/javaee"
xmlns:xsi
="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation
="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
>

当我把配置struts2的代码填进去之后,竟然报错:

1.struts2代码:

<display-name>我的第一个struts2程序</display-name>  <!-- 定义项目名称 -->>
<filter>
<filter-name>struts2</filter-name> <!-- 定义拦截器名称 -->
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>

<filter-mapping>
<filter-name>struts2</filter-name> <!-- 映射 -->
<url-pattern>/*</url-pattern> <!-- 模式匹配 -->
</filter-mapping>

2.报错:

Multiple annotations found at this line:
- cvc-complex-type.2.3: Element 'web-app' cannot have character [children], because the type's content
type is element-only.

后来发现,并不是struts2配置代码有问题,而是xml头文件中,第三行有问题:

xmlns="http://java.sun.com/xml/ns/javaee"

可能是一直用j2ee习惯?反正改成j2ee之后就好了。


posted @ 2012-03-14 09:14  lihui_yy  阅读(5836)  评论(1编辑  收藏  举报