今天才知道,有2种方法:
1、适用于所有的servlet:只需修改conf目录下的server.xml即可自动匿名访问所有的servlet。
To let Tomcat run anonymous servlet classes that have not been defined in a
web.xml file, you can enable the Tomcat "invoker" servlet by removing the comments around the
servlet-mapping element in the
web.xml file in the Tomcat
conf directory:
<!-- The mapping for the invoker servlet -->
<!--
<servlet-mapping>
<servlet-name>invoker</servlet-name>
<url-pattern>/servlet/*</url-pattern>
</servlet-mapping>
-->
When you edit web.xml in the Tomcat conf directory, the servlet is ready to go。
例如,after saving Ch09_06.java and building the project, start Tomcat with the Tomcat plug-in's buttons and navigate to http://localhost:8080/Ch09_06/servlet/org.eclipsebook.ch09.Ch09_06.
2、就是编辑每个项目中的web.xml文件:
lternatively, if you don't want to edit web.xml in the Tomcat conf directory to enable anonymous servlets, you can create a local web.xml for each project you create with the Tomcat plug-in.
posted on 2006-10-11 03:01
SmileFace 阅读(285)
评论(0) 编辑 收藏 所属分类:
Java-Studying