首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

Struts 1.x 在DispatchAction中获取web.xml中的配备参数

2012-10-28 
Struts 1.x 在DispatchAction中获取web.xml中的配置参数知道Action类的源头是一个Servlet的控制器,那个从w

Struts 1.x 在DispatchAction中获取web.xml中的配置参数

知道Action类的源头是一个Servlet的控制器,那个从web.xml中获取配置参数是可行的。

?

试验了一下果然成功。代码如下:

?

web.xml中配置参数

?

<context-param><param-name>pageSize</param-name><param-value>3</param-value></context-param>

?

DiapatchAction类中获取参数

?

try {this.pageSize = Integer.parseInt(servlet.getServletConfig().getServletContext().getInitParameter("pageSize"));} catch(Exception e) {this.pageSize = 10;}

?

试验成功

热点排行