使用@WebFilter和@WebServlet部署的Servlet 3问题 [英] Servlet 3 issues with @WebFilter and @WebServlet deployment
问题描述
我试图将我在 web.xml
文件中定义的现有servlet和过滤器迁移到 @WebServlet
和 @WebFilter
Glassfish V3服务器上的注释。
目前 web.xml
定义了12个servlet和6个过滤器。
尝试从 web.xml
文件中删除一个servlet,并将 @WebServlet
注释添加到Java servlet文件。 / b>
但是在我的JSP尝试访问Servlet Glassfish时抱怨Service Not Available无法访问servlet。
<基本上Servlet和过滤器是使用GlassFish Server 3从未标识的注释定义的。
这个注释不能与 web一起使用.xml
文件?
我们是否有任何解决方法。
我提到以下 Sun文档将web.xml迁移到servlet 3注释
您必须让web.xml正确,下面是您应该使用的web.xml的开头:
<?xml version =1.0encoding =UTF-8?>
< web-app
xmlns =http://java.sun.com/xml/ns/javaee
xmlns:xsi =http://www.w3.org / 2001 / XMLSchema-instance
metadata-complete =false
version =3.0
xsi:schemaLocation =http://java.sun.com/xml/ns/ javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd\">
I am trying to migrate my existing servlets and filters defined in web.xml
file to @WebServlet
and @WebFilter
annotations on Glassfish V3 server.
Currently web.xml
defined 12 servlets and 6 filters .
Tried removing one servlet from web.xml
file and added @WebServlet
annotation to Java servlet file .
But having difficulty in accessing the servlet when ever my JSP trying to access Servlet Glassfish complains "Service Not Available".
basically Servlet and filter defined using annotations never identified by Glassfish Server 3.
Is this existing bug that annotations can not be used along with web.xml
file ?
Do we have any workaround.
I referred following Sun documentation to migrate web.xml to servlet 3 annotations
You've got to get your web.xml correct, below is the beginning of the web.xml you should use:
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
metadata-complete="false"
version="3.0"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
这篇关于使用@WebFilter和@WebServlet部署的Servlet 3问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!