時沒有和解組豆我從org.springframework.security.core.userdetails.User並使用這個bean使用OpenID延伸的豆。豆看起來像:Spring可以使用Spring安全
package com.employee;
import java.util.Collection;
import javax.xml.bind.annotation.XmlRootElement;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.User;
@XmlRootElement(name="Employee")
public class Employee extends User{
private int empId;
private String deptName;
public Employee() {
super("", "unused", null);
}
public Employee(String username, Collection<GrantedAuthority> authorities) {
super(username, "unused", authorities);
}
public int getEmpId() {
return empId;
}
public void setEmpId(int empId) {
this.empId = empId;
}
public String getDeptName() {
return deptName;
}
public void setDeptName(String deptName) {
this.deptName = deptName;
}
}
的控制器接受Employee的一個實例爲:
@RequestMapping(值= 「/addEmp.do」, 方法= RequestMethod.POST) 公共字符串@ResponseBody addEmployee (@RequestBody僱員EMP){...}
我已將與隨動體的POST請求:
<?xml version="1.0" encoding="UTF-8"?>
<Employee>
<empId>10</empId>
<deptName>abc</deptName>
</Employee>
但是,得到以下JAXB異常上調用addEmp操作:
2012-12-16 15:25:55,364{HH:mm:ss} DEBUG [http-bio-8080-exec-1] (AbstractHandlerExceptionResolver.java:132) -
Resolving exception from handler [public java.lang.String com.main.EmpController.addEmployee(com .employee.Employee)]:
org.springframework.http.converter.HttpMessageNotReadableException: Could not unmarshal to
[class com.employee.Employee]: Unable to create an instance of com.employee.Employee; nested exception is
javax.xml.bind.UnmarshalException: Unable to create an instance of com.employee.Employee
你肯定有什麼更多的從JAXB的日誌?您是否嘗試過使用此輸入手動調用JAXB(在某個遊樂場項目中)? –