简体   繁体   中英

Access context param from a class inside lib jar

是否可以从lib中的jar或普通的Java类访问上下文参数?

You didn't mention which framework you are using but assuming you are using HttpServlet you can use getServletContext method to retrieve the ServletContext and then you can retrieve context parameters by getInitParameter(String) method.

ServletContext ctx = getServletContext();
String dbDriver = ctx.getInitParameter( "your_parameter_name" );

You can read more about HttpServlet , ServletContext and getServletContext method .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM