`

HttpServletRequest对象getParameter()方法在各web容器中返回值问题

    博客分类:
  • j2ee
阅读更多
Servlet中HttpServletRequest对象的getParameter(“arg”)方法,如果"arg"参数不存在,在各web容器中的返回值不同,经过测试,在tomcat中request.getParameter()方法在参数不存在的情况下,返回null,而在weblogic和websphere下返回值为“空串”,所以建议在判断request.getParameter()返回值时,同时判断null和空串。
String name=request.getParameter("name");
if(name!=null&&!"".equals(name))
{
        //business
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics