最近在一个项目的web.xml文件中配置servlet的init-param 参数时总是报红叉,后来仔细查看了下,终于找到了原因,原来是把servlet-class 和 init-param的顺序放错了。囧
原始web.xml配置:
<servlet>
<servlet-name>serviceProvide</servlet-name>
<init-param>
<param-name>file_csc_service</param-name>
<param-value>/service/csc_service.xml</param-value>
</init-param>
<servlet-class>
com.srt.vas.cs.common.ServiceProvideServlet
</servlet-class>
</servlet>
正确配置:
<servlet>
<servlet-name>serviceProvide</servlet-name>
<servlet-class>
com.srt.vas.cs.common.ServiceProvideServlet
</servlet-class>
<init-param>
<param-name>file_csc_service</param-name>
<param-value>/service/csc_service.xml</param-value>
</init-param>
</servlet>