我在GWT中开发了一个简单的应用程序。之后,我生成war文件并将其部署到JBoss中。但是,当我这样做时,我收到如下错误消息:
元素类型“web-app”的内容 必须匹配 “(图标?,显示名称?,描述?,分发?,的context-param *,滤波器*,过滤器 - 映射*,听者*,* servlet的,servlet的映射*,会话配置?,MIME映射*,欢迎文件列表?,错误页*,*的taglib,资源ENV-REF *,资源 - REF *,安全约束*,登录-配置?,安全角色*,ENV进入*,EJB-REF *,EJB本地-REF *)。”
另一方面,我的web.xml如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/resources/spring.xml</param-value>
</context-param>
<!-- Servlets -->
<servlet>
<servlet-name>greetServlet</servlet-name>
<servlet-class>main.java.com.gwt.app.server.GreetingServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>greetServlet</servlet-name>
<url-pattern>/zb_app/greet</url-pattern>
</servlet-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener- class>
</listener>
<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>ZB_app.html</welcome-file>
</welcome-file-list>
</web-app>
也就是说,web-app标签包含一些必需的标签。我不是什么问题,有人可以帮我解决这个问题吗?
提前谢谢!
问候!
答案 0 :(得分:1)
尝试将监听器声明放在servlet之前,元素的顺序应该不是问题,但我已经在某个容器中看到了这一点(如果是JBoss则不记得)
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Servlets -->
<servlet>
<servlet-name>greetServlet</servlet-name>
<servlet-class>main.java.com.gwt.app.server.GreetingServiceImpl</servlet-class> </servlet>
<servlet-mapping>
<servlet-name>greetServlet</servlet-name>
<url-pattern>/zb_app/greet</url-pattern>
</servlet-mapping>
答案 1 :(得分:1)
序列应该是context-param - listener - servlet,这里是
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/resources/spring.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>greetServlet</servlet-name>
<servlet-class>main.java.com.gwt.app.server.GreetingServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>greetServlet</servlet-name>
<url-pattern>/zb_app/greet</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>ZB_app.html</welcome-file>
</welcome-file-list>
</web-app>