java HttpServletRequest 属性值

    public static void test(HttpServletRequest request, HttpServletResponse response) throws IOException {
        request.setCharacterEncoding("UTF-8");
        response.setCharacterEncoding("UTF-8");
        response.setContentType("text/plain;charset=utf-8");
        PrintWriter out = response.getWriter();
        out.println("AuthType=" + request.getAuthType());
        out.println("CharacterEncoding=" + request.getCharacterEncoding());
        out.println("ContentLength=" + request.getContentLength());
        out.println("ContentType=" + request.getContentType());
        out.println("ContextPath=" + request.getContextPath());
        out.println("LocalAddr=" + request.getLocalAddr());
        out.println("LocalName=" + request.getLocalName());
        out.println("LocalPort=" + request.getLocalPort());
        out.println("Method=" + request.getMethod());
        out.println("PathInfo=" + request.getPathInfo());
        out.println("PathTranslated=" + request.getPathTranslated());
        out.println("Protocol=" + request.getProtocol());
        out.println("QueryString=" + request.getQueryString());
        out.println("RemoteAddr=" + request.getRemoteAddr());
        out.println("RemoteHost=" + request.getRemoteHost());
        out.println("RemotePort=" + request.getRemotePort());
        out.println("RemoteUser=" + request.getRemoteUser());
        out.println("RequestedSessionId=" + request.getRequestedSessionId());
        out.println("RequestURI=" + request.getRequestURI());
        out.println("Scheme=" + request.getScheme());
        out.println("ServerName=" + request.getServerName());
        out.println("ServerPort=" + request.getServerPort());
        out.println("ServletPath=" + request.getServletPath());
        out.println("Local=" + request.getLocale());
        out.println("RequestedURL=" + request.getRequestURL());
        out.flush();
        out.close();

        System.out.println("AuthType=" + request.getAuthType());
        System.out.println("CharacterEncoding=" + request.getCharacterEncoding());
        System.out.println("ContentLength=" + request.getContentLength());
        System.out.println("ContentType=" + request.getContentType());
        System.out.println("ContextPath=" + request.getContextPath());
        System.out.println("LocalAddr=" + request.getLocalAddr());
        System.out.println("LocalName=" + request.getLocalName());
        System.out.println("LocalPort=" + request.getLocalPort());
        System.out.println("Method=" + request.getMethod());
        System.out.println("PathInfo=" + request.getPathInfo());
        System.out.println("PathTranslated=" + request.getPathTranslated());
        System.out.println("Protocol=" + request.getProtocol());
        System.out.println("QueryString=" + request.getQueryString());
        System.out.println("RemoteAddr=" + request.getRemoteAddr());
        System.out.println("RemoteHost=" + request.getRemoteHost());
        System.out.println("RemotePort=" + request.getRemotePort());
        System.out.println("RemoteUser=" + request.getRemoteUser());
        System.out.println("RequestedSessionId=" + request.getRequestedSessionId());
        System.out.println("RequestURI=" + request.getRequestURI());
        System.out.println("Scheme=" + request.getScheme());
        System.out.println("ServerName=" + request.getServerName());
        System.out.println("ServerPort=" + request.getServerPort());
        System.out.println("ServletPath=" + request.getServletPath());
        System.out.println("Local=" + request.getLocale());
        System.out.println("RequestedURL=" + request.getRequestURL());
    }
时间: 2024-12-22 10:25:29

java HttpServletRequest 属性值的相关文章

java反射获取对象的属性值和对象属性中的子属性值

近段时间在做web项目,前端使用的是jQuery EasyUI. 为方便需要,准备做一个前端通用的Datagird导出Excel功能,博主也考虑过思路和最终功能,1.前端选中行导出:2.当前页导出:3.当前过滤条件导出. 想偷懒在网上找找已有的代码改改,发现大部分只能满足个别需求,使用JS导出只能满足前端,使用代码才能实现3功能. ...... 好了,说了一堆废话,回归正题,本文是在做通用自定义字段导出时所需要,根据属性名去查找对象和子对象,找到对应属性值,抓取回来放到Excel中. 直接上代码

java获取对象属性类型、属性名称、属性值

因为项目需要用到,于是简单封装了一些常用的操作: [java] view plaincopy /** * 根据属性名获取属性值 * */ private Object getFieldValueByName(String fieldName, Object o) { try { String firstLetter = fieldName.substring(0, 1).toUpperCase(); String getter = "get" + firstLetter + field

java 反射实现不同对象相同属性值复制

1.此方法会过滤final字段 2.此方法会过滤对象字段 3.此方法会兼容同对象之间.不同对象之间属性值复制 package com.bin.design.util; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.Arrays; import java.util.List; import com.bin.des

java使用反射比较两个bean对象属性值是否相等

import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.HashMap; import java.util.Map; import org.apache.log4j.Logger; public class DomainEquals { /** * 日志操作类 */ private static Logger logger = Logger.getLogger(DomainEquals.c

java利用映射表名称反射创建实体类并赋属性值

1.hibernate中首先进行初始化,将对应的表名和类名以键值对的方式存放到map中 private Map<String, String> mappings;//全局变量 /** * 根据数据库表名获取实体类 */ public void initMappings() { if (mappings == null) { mappings = new HashMap<String, String>(); SessionFactory factory = this.getSessi

java中如何遍历实体类的属性和数据类型以及属性值

1 package com.walkerjava.test; 2 3 import java.lang.reflect.Field; 4 import java.lang.reflect.InvocationTargetException; 5 import java.lang.reflect.Method; 6 import java.util.Date; 7 8 /*** 9 * 遍历实体类的属性和数据类型以及属性值 10 * 11 * @author LiBaozhen 12 * @dat

java 反射: 当Timestamp类型的属性值为null时,设置默认值

import java.beans.PropertyDescriptor; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.sql.Timestamp; class Person { private String name; private int age; private Timestamp birth; public Timestamp getBirth() { return birth

Java反射设置和访问私有属性值

越学习到后面,越感觉java反射机制很重要,必须精通,要不框架那块比较难自己动手实现,回过头温习一下反射机制,查漏补缺 今天尝试了一下通过反射访问和设置类的私有属性(不设置settesr和getters),比较容易理解,代码一贴就知道了 下面是po代码: package cn.liangqinghai.reflect; public class Beans1 { public Beans1(){ System.out.println("无参构造调用"); } public Beans1

java 中利用反射机制获取和设置实体类的属性值

JAVA反射机制是在运行状态中,对于任意一个类,都能够知道这个类的所有属性和方法:对于任意一个对象,都能够调用它的任意一个方法和属性:这种动态获取的信息以及动态调用对象的方法的功能称为java语言的反射机制. JAVA反射(放射)机制:"程序运行时,允许改变程序结构或变量类型,这种语言称为动态语言".从这个观点看,Perl,Python,Ruby是动态语言,C++,Java,C#不是动态语言.但是JAVA有着一个非常突出的动态相关机制:Reflection,用在Java身上指的是我们可