ServletContext sctx = getServletContext();//创建ServletContext对象 String 参数值 = sctx.getInitParameter(String 参数名);
[quote=引用 6 楼 NNTT2010 的回复:] 一般用户配置都封装在properties文件中, 假如楼主真要存放在web.xml中,那么也可以读取,但是一定要在servlet中 如 public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String 参数值 = this.getServletContext().getInitParameter("参数名"); }
一般用户配置都封装在properties文件中, 假如楼主真要存放在web.xml中,那么也可以读取,但是一定要在servlet中 如 public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String 参数值 = this.getServletContext().getInitParameter("参数名"); }
81,092
社区成员
341,716
社区内容
加载中
试试用AI创作助手写篇文章吧