当前位置: 代码迷 >> Java Web开发 >> 不实施action,但是可以执行validation
  详细解决方案

不实施action,但是可以执行validation

热度:7322   发布时间:2013-02-25 21:15:38.0
不执行action,但是可以执行validation
我想点击注册按钮执行RegisterAction中的execute方法。可设置断点没有执行,直接给我的实体赋空值,报了异常

jsp页面----------------------------------------------------------------------------------------------
<%@ taglib uri="/struts-dojo-tags" prefix="sx"%>
<html>
  <head>
  <title>注册</title>
  </head>
  <body>
  <s:form action="register" method="post" namespace="/">
  <s:textfield name="user.loginId" label="用户名"/>
  <s:textfield name="user.password" label="密码"/>
  <s:textfield name="rePassword" label="确认密码"/>
  <s:textfield name="user.phone" label="电话"/>
  <s:textfield name="user.userName" label="用户名"/>
  <s:submit value="注册"/>  
  </s:form>  
  </body>
</html>

struts.xml----------------------------------------------------------------------

<package name="default" extends="struts-default" namespace="/">
  <action name="register" class="com.accp.test.action.RegisterAction">
  <result name="input">login.jsp</result>
  </action>
 </package>
</struts>  
Action---------------------------------------------------------------------------------

public class RegisterAction extends ActionSupport {
@Override
public String execute() throws Exception {
System.out.println("123");
return NONE;
}
}
异常--------------------------------------------------------------------------------- --------
2012-7-17 20:11:56 com.opensymphony.xwork2.util.logging.commons.CommonsLogger error
严重: Could not create and/or set value back on to object
java.lang.InstantiationException: com.accp.test.entity.User
at java.lang.Class.newInstance0(Class.java:340)
at java.lang.Class.newInstance(Class.java:308)
at com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:119)
at com.opensymphony.xwork2.conversion.impl.InstantiatingNullHandler.createObject(InstantiatingNullHandler.java:148)
at com.opensymphony.xwork2.conversion.impl.InstantiatingNullHandler.nullPropertyValue(InstantiatingNullHandler.java:126)
at com.opensymphony.xwork2.ognl.OgnlNullHandlerWrapper.nullPropertyValue(OgnlNullHandlerWrapper.java:21)
at ognl.ASTProperty.getValueBody(ASTProperty.java:118)
at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212)
at ognl.SimpleNode.getValue(SimpleNode.java:258)
at ognl.ASTChain.setValueBody(ASTChain.java:222)
at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:220)
at ognl.SimpleNode.setValue(SimpleNode.java:301)
at ognl.Ognl.setValue(Ognl.java:737)
at com.opensymphony.xwork2.ognl.OgnlUtil.setValue(OgnlUtil.java:198)
at com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:161)
at com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:149)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.setParameters(ParametersInterceptor.java:276)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:187)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
  相关解决方案