Tomcat6中启用invoker心得

今天下了看了一下示例,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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值