SSH提示ognl.OgnlException: target is null for setProperty

awfiitihc 2013-01-08 03:45:58
找了好久都不知道错在哪里
错误信息:

ognl.OgnlException: target is null for setProperty(null, "action", [Ljava.lang.String;@d37bdd)
at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:2309)
...
2013-01-08 13:06:000,472 [com.opensymphony.xwork2.ognl.OgnlValueStack]-[WARN] Error setting expression 'user.usercode' with value '[Ljava.lang.String;@1daabbf'
ognl.OgnlException: usercode [java.lang.IllegalArgumentException: argument type mismatch]
at ognl.ObjectPropertyAccessor.setPossibleProperty(ObjectPropertyAccessor.java:103)
at ognl.ObjectPropertyAccessor.setProperty(ObjectPropertyAccessor.java:162)
...

2013-01-08 13:06:000,475 [com.opensymphony.xwork2.ognl.OgnlValueStack]-[WARN] Error setting expression 'user.username' with value '[Ljava.lang.String;@1e33b76'
ognl.OgnlException: username [java.lang.IllegalArgumentException: argument type mismatch]
at ognl.ObjectPropertyAccessor.setPossibleProperty(ObjectPropertyAccessor.java:103)
at ognl.ObjectPropertyAccessor.setProperty(ObjectPropertyAccessor.java:162)
...


struts.xml:
<struts>
<constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory"></constant>

<package name="user" extends="struts-default" >
<action name="user?*" class="account" method="{1}">
<result name="success">/success.jsp</result>
</action>
</package>

</struts>



applicationContext.xml:
<beans default-autowire="byName">
<bean id="user" class="com.tsai.space.vo.UserVO" />
<bean id="account" class="com.tsai.space.controller.Account" />
</beans>


action类Account:

public class Account extends ActionSupport {
public UserVO user;
/**
*
*/
private static final long serialVersionUID = 5592712600588043181L;

public Account() {
super();
}
public UserVO getUser() {
return user;
}
public void setUser(UserVO user) {
this.user = user;
}


JSP:

<s:form action="/user/user?register.action" method="post" >
<s:textfield name="user.username" label="用户名"></s:textfield><br>
<s:textfield name="user.usercode" label="密码"></s:textfield><br>
<s:submit value="注册" ></s:submit>
</s:form>

...全文
464 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
bobo1232 2015-04-13
  • 打赏
  • 举报
回复

有问题
longzl123 2015-04-13
  • 打赏
  • 举报
回复
没有get/set 那个user对象
Cute_Tiger 2013-03-29
  • 打赏
  • 举报
回复
<s:textfield name="user.username" label="用户名"></s:textfield><br> <s:textfield name="user.usercode" label="密码"></s:textfield><br> 这里的username,usercode和你的javaBean里面的大小写都不一样,注意到了没
caipan1234567 2013-02-05
  • 打赏
  • 举报
回复
user.usercode 改成 user.userCode
子晓聊技术 2013-02-03
  • 打赏
  • 举报
回复
你把 <s:form action="/user/user?register.action" method="post" >这句话去掉.action,改成这样 <s:form action="/user/user?register" method="post" > 试一试
  • 打赏
  • 举报
回复
<s:textfield name="user.username" label="用户名"></s:textfield><br> private String userName; private String userCode; 看看是不是这块不一致
awfiitihc 2013-01-08
  • 打赏
  • 举报
回复

UserVO
public class UserVO implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = -7468298057329693235L;
	private Integer id;
	private String userName;
	private String userCode;
	private Integer userAge;
	private boolean userSex;
	private String userBirth;
	private String userMail;
	public UserVO() {
		super();
	}
	
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	public String getUserCode() {
		return userCode;
	}
	public void setUserCode(String userCode) {
		this.userCode = userCode;
	}
	public Integer getUserAge() {
		return userAge;
	}
	public void setUserAge(Integer userAge) {
		this.userAge = userAge;
	}
	public boolean isUserSex() {
		return userSex;
	}
	public void setUserSex(boolean userSex) {
		this.userSex = userSex;
	}
	public String getUserBirth() {
		return userBirth;
	}

	public void setUserBirth(String userBirth) {
		this.userBirth = userBirth;
	}

	public String getUserMail() {
		return userMail;
	}
	public void setUserMail(String userMail) {
		this.userMail = userMail;
	}
	
	
}
傲雪kimi 2013-01-08
  • 打赏
  • 举报
回复
引用 1 楼 ahuter9 的回复:
楼主可否贴一下User这个类
不好意思是UserVO
傲雪kimi 2013-01-08
  • 打赏
  • 举报
回复
楼主可否贴一下User这个类

81,107

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧