单个Servlet的配置对象
web.xml文章来源:https://www.toymoban.com/news/detail-646740.html
<servlet>
<servlet-name>FirstServlet</servlet-name>
<servlet-class>com.ambow.test.FirstServlet</servlet-class>
<init-param>
<param-name>charset</param-name>
<param-value>utf-8</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>FirstServlet</servlet-name>
<url-pattern>/first01</url-pattern>
</servlet-mapping>
获取单个Servlet的初始化参数文章来源地址https://www.toymoban.com/news/detail-646740.html
ServletConfig config;
@Override
public void init(ServletConfig config) throws ServletException {
super.init(config);
this.config = config;
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String charset = config.getInitParameter("charset");//获取初始化参数
...
}
到了这里,关于Java课题笔记~ ServletContext的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!