我需要将我的网络服务器中的网址指向:
http://localhost:8080/console/myws/mymethod
我有一个名为MyServlet的servlet类 使用一些方法(最终是使用JAXWS转换的Web服务) 如果可能的话,我怎样才能将这个servlet映射到tomcat服务器而不改变servlet类名:
http://localhost:8080/console/myws/mymethod
这是我的web.xml配置,我无法使其工作。我将控制台定义为我的Context root而不是“/”只是控制台
<listener>
<listener-class>com.sun.xml.ws.transport.http.servlet.WSServletContextListener</listener-class>
</listener>
<servlet>
<servlet-name>jax-ws</servlet-name>
<servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>jax-ws</servlet-name>
<url-pattern>/myws/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
90
</session-timeout>
</session-config>
我怎么能在tomcat中调试配置来检查我做错了什么?
答案 0 :(得分:2)
假设/console
是上下文路径而/mymethod
是路径信息,那么您需要在/myws/*
上映射servlet。
<servlet-mapping>
<servlet-name>yourServletName</servlet-name>
<url-pattern>/myws/*</url-pattern>
</servlet-mapping>
servlet类和名称完全独立于您选择的URL模式,因此您根本不需要更改它。