日期:2014-05-17  浏览次数:20729 次

web.xml配置servlet
现有的servlet的配置如下:
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>com.momentek.ums.mms.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>

我们总监写了一个servlet的代理类,我们在WEB-INF/classes下面建web文件夹,在把代理类放进去(代理类是*.class的文件),要在web.xml怎样进行配置,使代理类和程序关联起来?知道的请给我把具体的web.xml这里的配置写一下,谢谢!


------解决方案--------------------
如果代理类是Proxy.class的文件
那么在web.xml里添加如下代码
XML code


<servlet>
<servlet-name>proxy</servlet-name>
<servlet-class>web.Proxy</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>proxy</servlet-name>
<url-pattern>*</url-pattern>
</servlet-mapping>

------解决方案--------------------
XML code
<servlet>
        <servlet-name>proxy</servlet-name>
        <servlet-class>web.ServletProxy</servlet-class>
        <init-param>
            <param-name>proxyHost</param-name>
            <param-value>192.168.18.162</param-value>
             </init-param>
            <init-param>
            <param-name>proxyPort</param-name>
            <param-value>8080</param-value>
             </init-param>
             <init-param>
            <param-name>proxyPath</param-name>
            <param-value>/mms</param-value>
             </init-param>
              
    </servlet>
    
    <servlet-mapping>
        <servlet-name>proxy</servlet-name>
        <url-pattern>/mms/*</url-pattern>
    </servlet-mapping>