zoukankan      html  css  js  c++  java
  • getParameter和getAttribute的区别

    转自http://blog.csdn.net/java_xiaobin/article/details/45363897

    1.getAttribute是取得jsp中 用setAttribute設定的attribute 

    2.parameter得到的是string;attribute得到的是object 
    3.request.getParameter()方法传递的数据,会从Web客户端传到Web服务器端,代表HTTP请求数据;request.setAttribute()和getAttribute()方法传递的数据只会存在于Web容器内部,在具有转发关系的Web组件之间共享。即request.getAttribute()方法返回request范围内存在的对象,而request.getParameter()方法是获取http提交过来的数据。

    总结:

    getattribute一般在前台用与获取后台转发值

    getParameter一般在后台用于获取前台请求值

    getParameter  返回的是String 用于读取参数中的值;       
    getAttribute   返回的是Object,需进行转换,可用setAttribute设置成任意对象,使用很灵活,可随时用;

    getParameter  获取请求值       
    getAttribute   获取转发值

  • 相关阅读:
    3、Ubantu下安装nginx
    2、关于mongodb外部访问不成功的问题
    1. libcurl.so.4: cannot open shared object file: No such file or directory
    Php 笔记
    Jade之Plain Text
    Jade之Mixins
    Jade之Interpolation
    Jade之Template Inheritance
    Jade之Includes
    Jade之Filters
  • 原文地址:https://www.cnblogs.com/wangshen31/p/8335363.html
Copyright © 2011-2022 走看看