ITeye博客

achieve2015的博客

achieve2015 · 共 4 篇文章

把Strings转换成int和把int转换成String

String a = String.valueOf(2); //integer to numeric string int i = Integer.parseInt(a); //numeric string to an int String a = String.valueOf(2); //integer to numeric string int i = Integer.parseInt(a); //numeric string to an int

2016-01-11 14:15 · 评论(0)

httpservletrequest paramater

1、request.getRequestURL() 返回的是完整的url,包括Http协议,端口号,servlet名字和映射路径,但它不包含请求参数。 2、request.getRequestURI() 得到的是request URL的部分值,并且web容器没有decode过的 3、request.getContextPath() 返回 the context of the request. 4、request.getServletPath() 返回调用servlet部分的url. 5、request.getQueryString() 返回url路径?后面的查询字符串 示例: 当前url:h…

2016-01-11 14:04 · notes · 评论(0)

get client IP address

public String getIpAddr(HttpServletRequest request){ String ipAddress = null; ipAddress = request.getHeader("x-forwarded-for"); if(ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) { ipAddress = request.getHeader("Proxy-Client-IP"); } if(ipAddress == null || ipA…

2016-01-11 13:55 · notes · 评论(0)

中文参数乱码

1.指定编码UTF-8 传递页面 URLEncoder.encode(name,"UTF-8") 获取页面 String name=new String(request.getPatameter(name).getBytes("ISO_8859-1"),"UTF-8"); 2.默认平台编码 传递页面 URLEncoder.encode(name); 获取页面 String name=new String(request.getPatameter(name).getBytes("ISO_8859-1)); 3.url编码 传递 encodeURIComponent(url) 获取 decode…

2016-01-11 13:26 · notes · 评论(0)