构建context

public FBSContext build() throws Exception {
log.debug("FBS Build Context!");
// 构建context对象
FBSContext context = new FBSContext();
FBSContext.setContext(context);
try {
// 将request Parameter中的参数存入context
log.debug("FBS put Request Paramters to Context!");
for (Enumeration<String> paramNames = getHttpRequest()
.getParameterNames(); paramNames.hasMoreElements();) {
String name = paramNames.nextElement();
context.putParamter(name, getHttpRequest().getParameter(name));
}
// 将request Attribute中的参数存入context
log.debug("FBS put Request Attribute to Context!");
for (Enumeration<String> attributeNames = getHttpRequest()
.getAttributeNames(); attributeNames.hasMoreElements();) {
String name = attributeNames.nextElement();
context.putParamter(name, getHttpRequest().getAttribute(name));
}
// 将HttpRequest对象和HttpResponse对象存入Context
log.debug("FBS put Request to Context!");
context.putParamter(FBSContext.HTTP_REQUEST, getHttpRequest());
log.debug("FBS put Response to Context!");
context.putParamter(FBSContext.HTTP_RESPONSE, getHttpResponse());
} catch (FBSContextException e) {
log.error("FBS web http context build error!");
throw e;
}
return context;
}


structs2方法
Map<String, Object> map = ActionContext.getContext()
.getParameters();// ActionContext.getContext().getContextMap();
if (map != null && map.size() > 0) {
Set<String> keySet = map.keySet();
for (Iterator<String> iterator = keySet.iterator(); iterator
.hasNext();) {
String key = iterator.next();
if (key != null && map.get(key) != null) {
context.putParamter(key, map.get(key));
}
}
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值