javax.servlet.ServletException: BeanUtils.populate
javax.servlet.ServletException:BeanUtils.populateorg.apache.struts.util.RequestUtils....
javax.servlet.ServletException: BeanUtils.populate
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:495)
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:816)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:203)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
root cause
java.lang.IllegalArgumentException: Cannot invoke com.cn.struts.form.UserForm.setUser - argument type mismatch
org.apache.commons.beanutils.PropertyUtilsBean.invokeMethod(PropertyUtilsBean.java:1778)
org.apache.commons.beanutils.PropertyUtilsBean.setSimpleProperty(PropertyUtilsBean.java:1759)
org.apache.commons.beanutils.PropertyUtilsBean.setNestedProperty(PropertyUtilsBean.java:1648)
org.apache.commons.beanutils.PropertyUtilsBean.setProperty(PropertyUtilsBean.java:1677)
org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:1022)
org.apache.commons.beanutils.BeanUtilsBean.populate(BeanUtilsBean.java:811)
org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:298)
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:493)
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:816)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:203)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
这是我的UserAction的方法
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws IOException {
UserForm userForm = (UserForm) form;// TODO Auto-generated method stub
boolean login=this.getKUserBiz().login(userForm);
if(login){
request.getSession().setAttribute("User", userForm.getUser());
response.sendRedirect("house.do?param=toList"); }
return mapping.findForward("fail");
}
Biz层
public boolean login(UserForm form) {
KUsers user=form.getUser();
KUsers u=this.getKUserDao().findById(user.getKUsersId());
if(null!=u && null!=user.getKUsersPassword()&& user.getKUsersPassword().equals(u.getKUsersPassword())){
form.setUser(u);return true;}else{return false;}}
UserFrom里的代码
private KUsers user=null;
public UserForm()
{this.user=new KUsers();}
public KUsers getUser() {
return user;}
public void setUser(KUsers user) {
this.user = user;} 展开
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:495)
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:816)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:203)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
root cause
java.lang.IllegalArgumentException: Cannot invoke com.cn.struts.form.UserForm.setUser - argument type mismatch
org.apache.commons.beanutils.PropertyUtilsBean.invokeMethod(PropertyUtilsBean.java:1778)
org.apache.commons.beanutils.PropertyUtilsBean.setSimpleProperty(PropertyUtilsBean.java:1759)
org.apache.commons.beanutils.PropertyUtilsBean.setNestedProperty(PropertyUtilsBean.java:1648)
org.apache.commons.beanutils.PropertyUtilsBean.setProperty(PropertyUtilsBean.java:1677)
org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:1022)
org.apache.commons.beanutils.BeanUtilsBean.populate(BeanUtilsBean.java:811)
org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:298)
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:493)
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:816)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:203)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
这是我的UserAction的方法
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws IOException {
UserForm userForm = (UserForm) form;// TODO Auto-generated method stub
boolean login=this.getKUserBiz().login(userForm);
if(login){
request.getSession().setAttribute("User", userForm.getUser());
response.sendRedirect("house.do?param=toList"); }
return mapping.findForward("fail");
}
Biz层
public boolean login(UserForm form) {
KUsers user=form.getUser();
KUsers u=this.getKUserDao().findById(user.getKUsersId());
if(null!=u && null!=user.getKUsersPassword()&& user.getKUsersPassword().equals(u.getKUsersPassword())){
form.setUser(u);return true;}else{return false;}}
UserFrom里的代码
private KUsers user=null;
public UserForm()
{this.user=new KUsers();}
public KUsers getUser() {
return user;}
public void setUser(KUsers user) {
this.user = user;} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询