web.xml中init-param的作用

自闭症网瘾萝莉.ら 提交于 2020-01-25 18:12:11

定制初始化参数:可以定制servlet、JSP、Context的初始化参数,然后可以再servlet、JSP、Context中获取这些参数值。下面拿servlet来举例:

  <servlet>
    <servlet-name>dispatcherServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>classpath:springmvc.xml</param-value>
    </init-param>
  </servlet>

经过上面的配置,在servlet中能够调用getServletConfig().getInitParameter(“contextConfigLocation”)获得参数名对应的值。

参考:
https://www.cnblogs.com/fnlingnzb-learner/p/6560774.html

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!