使用request.getAttribute() 获取 form 表单中数据的方法。

我在项目中发现:在控制页面,使用request.getAttribute() 来获取 显示页面中form 的数据,感觉很奇怪,因为form 表单中的数据只能通过 request.getParameter()来获取,为什么在我们的系统中可以使用 request.getAttribute() 获取form中的数据呢?经过一番分析,有以下发现:

一、在系统中的控制页面,有一个对操作权限检测的方法,在这个方法里面,就把表单中的数据做了处里,以下是处理的方法:

Enumeration en = request.getParameterNames ( ) ;
while (en.hasMoreElements ( ))
{
	String strName = (String) en.nextElement ( ) ;
	String strValue = request.getParameter ( strName ) ;
	String lowerCaseName = strName.toLowerCase();

	if (iToChinese == 1)
	{
		strValue = DataFormat.toChinese ( strValue ) ;
	}
	
	if (request.getAttribute ( strName ) == null)
	{
		request.setAttribute ( strName , strValue ) ;
		if (iToChinese == 1)
		{
			log4j.info ( "====== request.parameter < " + strName + "   : " + request.getAttribute ( strName ) + " >" ) ;
			m_CurrentAllURL.append("&" + strName + "=" + request.getAttribute ( strName ));
		}
	}
}

 二、需要说明的是:上述代码中有冗余代码,但是不影响大家的学习。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值