随笔 - 15, 文章 - 0, 评论 - 5, 引用 - 0
数据加载中……

2008年8月1日

4xx - 客户端错误

发生错误,客户端似乎有问题。例如,客户端请求不存在的页面,客户端未提供有效的身份验证信息。 ·400 - 错误的请求。
·401 - 访问被拒绝。IIS 定义了许多不同的 401 错误,它们指明更为具体的错误原因。这些具体的错误代码在浏览器中显示,但不在 IIS 日志中显示: ·401.1 - 登录失败。
·401.2 - 服务器配置导致登录失败。
·401.3 - 由于 ACL 对资源的限制而未获得授权。
·401.4 - 筛选器授权失败。
·401.5 - ISAPI/CGI 应用程序授权失败。
·401.7 – 访问被 Web 服务器上的 URL 授权策略拒绝。这个错误代码为 IIS 6.0 所专用。

·403 - 禁止访问:IIS 定义了许多不同的 403 错误,它们指明更为具体的错误原因: ·403.1 - 执行访问被禁止。
·403.2 - 读访问被禁止。
·403.3 - 写访问被禁止。
·403.4 - 要求 SSL。
·403.5 - 要求 SSL 128。
·403.6 - IP 地址被拒绝。
·403.7 - 要求客户端证书。
·403.8 - 站点访问被拒绝。
·403.9 - 用户数过多。
·403.10 - 配置无效。
·403.11 - 密码更改。
·403.12 - 拒绝访问映射表。
·403.13 - 客户端证书被吊销。
·403.14 - 拒绝目录列表。
·403.15 - 超出客户端访问许可。
·403.16 - 客户端证书不受信任或无效。
·403.17 - 客户端证书已过期或尚未生效。
·403.18 - 在当前的应用程序池中不能执行所请求的 URL。这个错误代码为 IIS 6.0 所专用。
·403.19 - 不能为这个应用程序池中的客户端执行 CGI。这个错误代码为 IIS 6.0 所专用。
·403.20 - Passport 登录失败。这个错误代码为 IIS 6.0 所专用。

·404 - 未找到。 ·404.0 -(无) – 没有找到文件或目录。
·404.1 - 无法在所请求的端口上访问 Web 站点。
·404.2 - Web 服务扩展锁定策略阻止本请求。
·404.3 - MIME 映射策略阻止本请求。

·405 - 用来访问本页面的 HTTP 谓词不被允许(方法不被允许)
·406 - 客户端浏览器不接受所请求页面的 MIME 类型。
·407 - 要求进行代理身份验证。
·412 - 前提条件失败。
·413 – 请求实体太大。
·414 - 请求 URI 太长。
·415 – 不支持的媒体类型。
·416 – 所请求的范围无法满足。
·417 – 执行失败。
·423 – 锁定的错误。

posted @ 2008-08-04 14:16 zhouzhou@ 阅读(297) | 评论 (1)编辑 收藏

小结 Commons BeanUtils

 

Commons BeanUtils 的官方网址:http://commons.apache.org/beanutils/

Commins BeanUtils是针对JavaBeans一般性操作的组件,可以用来对JavaBeans进行复制,属性的读取,设置,修改,还以动态构造JavaBeans对象。

使用这个组件需要三个Jar文件
其中两个是 commons-logging-1.1.1下的commons-logging-1.1.1.jar 和commons-logging-api-1.1.1.jar
剩下一个是   commons-beanutils-1.8.0-BETA   下的commons-beanutils-1.8.0-BETA.jar
把这三个加入到项目的构件路径下即可。

下面为一个简单的例子

新建User Profile Address BeanUtilsExample 四个类


1 User.java

package com.v503.zhouzhou;

public class User {
 private Long userId;
 private String username;
 private String password;
 private Profile profile;

 public Long getUserId() {
  return userId;
 }

 public  void setUserId(Long userId) {
  this.userId = userId;
 }

 public String getUsername() {
  return username;
 }

 public void setUsername(String username) {
  this.username = username;
 }

 public String getPassword() {
  return password;
 }

 public void setPassword(String password) {
  this.password = password;
 }

 public Profile getProfile() {
  return profile;
 }

 public void setProfile(Profile profile) {
  this.profile = profile;
 }

}

2 Profile.java

package com.v503.zhouzhou;

import java.util.Date;
import java.util.Map;

 

public class Profile {
 private Map<String, String> phone;
 private Address[] address;
 private Date birthDate;
 private String email;

 public Map<String, String> getPhone() {
  return phone;
 }

 public void setPhone(Map<String, String> phone) {
  this.phone = phone;
 }

 public Address[] getAddress() {
  return address;
 }

 public void setAddress(Address[] address) {
  this.address = address;
 }

 public Date getBirthDate() {
  return birthDate;
 }

 public void setBirthDate(Date birthDate) {
  this.birthDate = birthDate;
 }

 public String getEmail() {
  return email;
 }

 public void setEmail(String email) {
  this.email = email;
 }

}



3 Address.java

package com.v503.zhouzhou;

public class Address {
 private String postCode;
 private String country;
 private String city;
 private String addr;

 public Address() {

 }

 public Address(String postCode, String country, String city, String addr) {
  this.postCode = postCode;
  this.country = country;
  this.city = city;
  this.addr = addr;
 }

 public String getPostCode() {
  return postCode;
 }

 public void setPostCode(String postCode) {
  this.postCode = postCode;
 }

 public String getCountry() {
  return country;
 }

 public void setCountry(String country) {
  this.country = country;
 }

 public String getCity() {
  return city;
 }

 public void setCity(String city) {
  this.city = city;
 }

 public String getAddr() {
  return addr;
 }

 public void setAddr(String addr) {
  this.addr = addr;
 }

}



4 BeanUtilsExample.java


package com.v503.zhouzhou;

import java.lang.reflect.InvocationTargetException;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.beanutils.PropertyUtils;


public class BeanUtilsExamples {

 @SuppressWarnings("unused")
 private User prepareData() {
  Address[] address = { new Address("111111", "中国", "保定", "河北大学"),
    new Address("22222", "中国", "保定", "河北大学工商学院") };
  Profile profile = new Profile();
  profile.setBirthDate(new GregorianCalendar(1987, 04, 17).getTime());
  profile.setEmail("aa1987417@126.com");
  Map<String, String> phone = new HashMap<String, String>();
  phone.put("mobilephone", "1532222706");
  phone.put("home", "110");
  profile.setPhone(phone);
  profile.setAddress(address);

  User user = new User();
  user.setUserId(new Long(503));
  user.setUsername("zhouzhou");
  user.setProfile(profile);
  user.setPassword("hicc");
  return user;

 }

 public static void main(String[] args) {
  BeanUtilsExamples a = new BeanUtilsExamples();
  User user = a.prepareData();
  System.out.println("输出对象的属性值---------------------------------");
  try {
   System.out.println(BeanUtils.getProperty(user, "userId"));       //BeanUtils中读取属性的方法getProperty()
   System.out.println(BeanUtils.getProperty(user, "username"));
   System.out.println(BeanUtils.getProperty(user, "password"));
   System.out.println(BeanUtils.getProperty(user, "profile.email"));
   System.out.println(BeanUtils.getProperty(user, "profile.birthDate"));
   System.out.println(BeanUtils.getProperty(user, "profile.phone(home)"));
   System.out.println(BeanUtils.getProperty(user, "profile.phone(mobilephone)"));
   System.out.println(BeanUtils.getProperty(user, "profile.address[0].city"));
   System.out.println(PropertyUtils.getProperty(user, "profile.address[1].country"));
   
   User user2 = new User();
   BeanUtils.copyProperties(user2, user); //BeanUtils中复制属性的方法getProperty()

   System.out.println("输出复制属性的属性值-------------------------------");
   System.out.println(BeanUtils.getProperty(user, "username"));
   System.out.println(BeanUtils.getProperty(user, "profile.birthDate"));
   System.out.println(BeanUtils.getProperty(user, "profile.phone(home)"));
   System.out.println(BeanUtils.getProperty(user, "profile.address[0].city"));
   
   
   System.out.println("输出复制属性修改以后的属性值---------------------");
   BeanUtils.setProperty(user2, "userId", new Long(8888888));   //设置属性的方法
   PropertyUtils.setProperty(user2, "username", "周旭");
   BeanUtils.setProperty(user2, "profile.email", "549748067@qq.com");
   BeanUtils.setProperty(user2, "profile.birthDate", new GregorianCalendar(2008, 8, 1).getTime());
   BeanUtils.setProperty(user2, "profile.address[0]", new Address("6666666", "中国","紫园","保定"));
   System.out.println(BeanUtils.getProperty(user2, "userId"));
   System.out.println(BeanUtils.getProperty(user2, "username"));
   System.out.println(BeanUtils.getProperty(user2, "profile"));
   System.out.println(BeanUtils.getProperty(user2, "profile.email"));
   System.out.println(BeanUtils.getProperty(user2, "profile.birthDate"));
   System.out.println(BeanUtils.getProperty(user2, "profile.address[0].city"));

   System.out.println("与被复制属性值的对象的比较-------------------------------");
   System.out.println(BeanUtils.getProperty(user, "userId"));
   System.out.println(BeanUtils.getProperty(user, "username"));
   System.out.println(BeanUtils.getProperty(user, "profile"));
   System.out.println(BeanUtils.getProperty(user, "profile.email"));
   System.out.println(BeanUtils.getProperty(user, "profile.birthDate"));
   System.out.println(BeanUtils.getProperty(user, "profile.address[0].city"));
  } catch (IllegalAccessException e) {

   e.printStackTrace();
  } catch (InvocationTargetException e) {

   e.printStackTrace();
  } catch (NoSuchMethodException e) {

   e.printStackTrace();
  }

 }

}


 




 

posted @ 2008-08-01 10:38 zhouzhou@ 阅读(581) | 评论 (0)编辑 收藏