今天下了看了一下示例,TOMCAT6中启用invoker 访问servlet功能不行。
老是抛出 Tomcat 6, java.lang.SecurityException: Servlet of class org.apache.catalina.servlets.InvokerServlet is privileged and cannot b 异常。百试不爽。
找到的一片能解决的办法不过是英文的,看了半天终于搞懂意思了、
翻译一下、在TOMCAT6使用invoker功能。
1.在conf/web.xml中开启invoker .
<servlet>
<servlet-name>invoker</servlet-name>
<servlet-class>
org.apache.catalina.servlets.InvokerServlet
</servlet-class>
2.在你所想使用的那个web应用程序下的WEB-INF下的web.xml 开启invoker功能
<servlet-name>invoker</servlet-name>
<url-pattern>/servlet/*</url-pattern>
</servlet-mapping>
3.需要在 conf/context.xml 中的 根元素加上 privileged="true" 属性、
<Context reloadable="true" privileged="true" >
然后重启tomcat 一切都正常了。
原文如下:
<Context reloadable="true" privileged="true">
The invoker servlet lets you run servlets without first making changes to your Web application's deployment descriptor (i.e., the WEB-INF/web.xml file). Instead, you just drop your servlet into WEB-INF/classes and use the URL http://host/servlet/ServletName (or http://host/webAppName/servlet/ServletName once you start using your own Web applications. The invoker servlet is extremely convenient when you are learning and even when you are testing things doing your initial development. You almost certainly want to enable it when learning, but you should disable it again before deploying any real applications.
To enable the invoker servlet, uncomment the following servlet and servlet-mapping elements in install_dir/conf/web.xml. Do not confuse this Apache Tomcat-specific web.xml file with the standard one that goes in the WEB-INF directory of each Web application.
<servlet>
<servlet-name>invoker</servlet-name>
<servlet-class>
org.apache.catalina.servlets.InvokerServlet
</servlet-class>
...
</servlet>
...
<servlet-mapping>
<servlet-name>invoker</servlet-name>
<url-pattern>/servlet/*</url-pattern>
</servlet-mapping>
In Tomcat 6 (but not Tomcat 5.5), you also need the privileged="true" entry in the Context element of context.xml. See the previous section for an example.