问题描述
struts.xml:<actionname="updatebook"class="updateBookAction"><resultname="success"type="redirect">/booklist.action</result></action>Spring配置:<beanid="updateBookAction"class="com.zj.action.UpdateBookAction"scope="prototype"><propertyname="bs"ref="bs"></property></bean>action名字:UpdateBookActionUpdateBookAction-validation:<fieldname="book"><field-validatortype="visitor"><paramname="context">book</param><paramname="appendPrefix">true</param><message>book's</message></field-validator></field>Book-book-validation:<fieldname="name"><field-validatortype="requiredstring"><message>此项不能为空</message></field-validator></field><fieldname="author"><field-validatortype="requiredstring"><message>此项不能为空</message></field-validator></field><fieldname="price"><field-validatortype="required"><message>此项不能为空</message></field-validator><field-validatortype="int"><paramname="max">150</param><paramname="min">1</param><message>价格在${max},${min}之间</message></field-validator></field>jsp:<formaction="updatebook.action"method="post"><inputtype="hidden"name="book.id"value="<s:propertyvalue='book.id'/>">name:<inputtype="text"name="book.name"value="<s:propertyvalue='book.name'/>"alt="name"><br/>author:<inputtype="text"name="book.author"value="<s:propertyvalue='book.author'/>"alt="author"><br/>price:<inputtype="text"name="book.price"value="<s:propertyvalue='book.price'/>"alt="price"><br/><inputtype="submit"value="更新"></form>
解决方案
本帖最后由 z709325115 于 2010-05-14 15:45:15 编辑
解决方案二:
更新的时候都写正确时可以执行的。但是如果有一项没有通过验证就会报错。java.lang.RuntimeException:Invalidactionclassconfigurationthatreferencesanunknownclassnamed[updateBookAction]org.apache.struts2.convention.ConventionsServiceImpl.determineResultPath(ConventionsServiceImpl.java:100)org.apache.struts2.convention.ConventionUnknownHandler.determinePath(ConventionUnknownHandler.java:385)org.apache.struts2.convention.ConventionUnknownHandler.handleUnknownResult(ConventionUnknownHandler.java:274)com.opensymphony.xwork2.DefaultUnknownHandlerManager.handleUnknownResult(DefaultUnknownHandlerManager.java:76)com.opensymphony.xwork2.DefaultActionInvocation.createResult(DefaultActionInvocation.java:215)com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:356)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:266)com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:252)org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:179)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:130)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138)com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)rootcausejava.lang.ClassNotFoundException:updateBookActionorg.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358)org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:130)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(