- 浏览: 65834 次
- 性别:
- 来自: 西安
文章分类
最新评论
-
yujian58:
写得很好。
jquery easyui datagrid 列自适应窗口宽度 -
cy913417:
charles0801tom 写道这个分页支持SQL SERV ...
Mybatis3 generator的使用附demo 及sqlserver 分页插件 -
charles0801tom:
这个分页支持SQL SERVER 2000吗?
Mybatis3 generator的使用附demo 及sqlserver 分页插件
最近在做Struts2的服务端验证小demo时,遇到一个错误:
ognl.MethodFailedException: Method "setAge" failed for object demo.demo_11_6.lee.RegistAction@d2b116 [java.lang.NoSuchMethodException: demo.demo_11_6.lee.RegistAction.setAge([Ljava.lang.String;)] at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1265) at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:1454) at ognl.ObjectPropertyAccessor.setPossibleProperty(ObjectPropertyAccessor.java:85) at ognl.ObjectPropertyAccessor.setProperty(ObjectPropertyAccessor.java:162) at com.opensymphony.xwork2.ognl.accessor.ObjectAccessor.setProperty(ObjectAccessor.java:28) at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:2225) at com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor.setProperty(CompoundRootAccessor.java:65) at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:2225) at ognl.ASTProperty.setValueBody(ASTProperty.java:127) 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) at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:179) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:130) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:165) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:179) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52) at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488) at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174) at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:835) at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:640) at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1286) at java.lang.Thread.run(Thread.java:619) Caused by: java.lang.NoSuchMethodException: demo.demo_11_6.lee.RegistAction.setAge([Ljava.lang.String;) at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1206) ... 63 more /-- Encapsulated exception ------------\ java.lang.NoSuchMethodException: demo.demo_11_6.lee.RegistAction.setAge([Ljava.lang.String;) at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1206) at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:1454) at ognl.ObjectPropertyAccessor.setPossibleProperty(ObjectPropertyAccessor.java:85) at ognl.ObjectPropertyAccessor.setProperty(ObjectPropertyAccessor.java:162) at com.opensymphony.xwork2.ognl.accessor.ObjectAccessor.setProperty(ObjectAccessor.java:28) at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:2225) at com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor.setProperty(CompoundRootAccessor.java:65) at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:2225) at ognl.ASTProperty.setValueBody(ASTProperty.java:127) 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) at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:179) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:130) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:165) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:179) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52) at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488) at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174) at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:835) at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:640) at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1286) at java.lang.Thread.run(Thread.java:619) \--------------------------------------/
搜素资料后发现这里的Action中的age 给的是int型,就会报此异常。
解决办法就是讲int型改为Integer, 同时修改get,set方法即可解决~
发表评论
-
Struts2 指定某些请求或servlet不被拦截
2013-05-06 17:44 5360在正常的项目运行中,有时我们需要某些特定的url或者serv ... -
struts2 ognl 正则去html标签字符串截取
2012-09-12 09:54 1463<s:property value="#co ... -
Struts2 urlrewrite 多个参数 outbound-rule
2012-05-15 15:06 2589struts2 在页面结合其自身的标签, 使用urlrewri ... -
Struts2 返回json对象
2012-04-27 13:25 930struts2 在返回json是默认会将action中get ... -
struts2异常There is no Action mapped for namespace * and action name
2012-03-19 15:51 1176解决There is no Action mapped for ... -
No result defined for action * and result success
2012-05-08 08:37 1103近日在做Struts2+Spring3+Mybatis3框架 ... -
Struts2 中namespace 搜索action顺序
2012-03-19 15:23 960关于 Struts2 中namespace 搜索action ... -
利用Struts2 sort标签对指定集合元素t排序
2012-03-19 09:02 1569sort标签可用于对指定的集合元素进行排序,排序时,我们必须 ... -
struts2 循环标签之元素索引
2012-02-01 10:59 1503<!-- 在页面中实现自动增加的序号用iterator ... -
struts2 遍历Map最全的总结 .
2012-01-14 16:53 898Struts2中iterator标签遍历map总结 ... -
Struts2.1.8 客户端验证 validation
2011-12-27 12:58 987Struts2.1.8 在做客户端验证时,当form中给定 v ... -
学习Struts2的autocompleter使用
2011-12-16 16:44 1158Struts2的ajax主题在使用autocompleter ...
相关推荐
在XML验证中,会在struts-plugin.xml或struts.xml中配置Validator的引用,然后在单独的validation.xml文件中定义每个Action的验证规则。例如,对于用户名和密码,可以设置必填、长度限制等规则。 使用注解验证则更...
本文将详细介绍Struts2验证框架的基本原理、配置方法以及如何使用它进行客户端和服务端的验证。 #### 二、Struts2验证框架概述 Struts2框架内置了一套灵活且强大的验证机制,能够支持多种类型的验证规则,包括但不...
其中,Struts2的验证机制是其核心功能之一,能够帮助开发者轻松实现客户端和服务端的数据验证,确保数据的有效性和安全性。 ### 验证框架与Validation #### 验证框架概述 在Struts2中,验证主要分为两大类:...
- 配置Struts2的validation.xml文件,导入Hibernate Validator的约束声明。 4. **自定义校验逻辑**: - 当预定义的注解不能满足需求时,可以创建自定义校验器实现`ConstraintValidator`接口。 - 使用`@...
Struts2提供了一套强大的表单验证机制,可以实现客户端和服务端的验证。在ActionForm或Action类中,我们可以定义校验规则,并在用户提交表单时自动执行验证。 7. **国际化与本地化** Struts2支持多语言环境,我们...
要深入了解Struts2的检证框架,可以阅读其源码,特别是`org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor`和`org.apache.struts2.util.FieldHelper`等关键类,它们是验证过程的核心。...
Struts2框架提供了一套强大的校验机制,可以帮助开发者轻松实现客户端和服务端的数据验证。本文将通过一个具体的示例——`LoginAction-validation.xml`配置文件,来详细解析Struts2中的校验框架。 #### 二、Struts2...
9. **表单验证(Validation)**:Struts2提供了强大的表单验证机制,可以在客户端和服务端进行数据验证。 10. **插件机制**:Struts2的插件机制允许开发者轻松扩展框架功能,如Spring插件可以实现依赖注入,...
5. **整合JSR 303/JSR 349 Bean Validation**:Struts2也支持JSR 303/349标准,允许在实体类上直接应用Bean Validation的注解,如`@NotNull`, `@Size`, `@Pattern`等,实现跨框架的校验。 6. **动态字段校验**:...
10. **Validation框架**:内置了强大的表单验证机制,可以在客户端和服务端进行数据校验。 下载这个压缩包后,开发人员可以直接将包含的jar文件导入到自己的项目中,避免了逐一查找和下载每个依赖的繁琐过程。这些...
8. **性能优化**:FormValidator通常在服务端进行验证,可以避免无效的数据库查询和操作,提高系统的响应速度和安全性。 9. **文档和示例**:FormValidator项目通常会提供详尽的文档和示例代码,帮助开发者快速上手...
欢迎大家提出改进,以便框架完成的更好如果需要,我会在将来开发出与服务端结合的开发框架,如struts and struts2 并且感谢原作者这么棒的Idea: http://tetlaw.id.au/view/blog/really-easy-field-validation-w
7. **Validation(验证)**:Struts2提供了强大的表单验证机制,可以在客户端和服务端进行数据校验。 8. **国际化(i18n)**:Struts2支持多语言,通过资源包提供不同语言的文本。 9. **插件支持**:Struts2拥有...
Spring 2.5的事务管理功能使得开发者可以轻松地管理数据库事务,同时,它还提供了对JSR-303(Bean Validation)的支持,实现了数据验证。 这两个框架在实际项目中经常结合使用。Struts提供了一种有效的MVC架构,...
- **Validation Framework**:用于实现客户端和服务端的数据验证。 - **Struts TagLib**:一组自定义标签,简化了JSP页面的编写。 - **BeanUtils**:提供了一些实用工具方法来操作Bean。 - **Collections**:...
4. **配置文件**:如`conf`目录下的`validation.xml`,这是Validator的核心配置文件,用于定义验证规则和验证组。开发者可以根据需求自定义或扩展这些配置。 5. **JAR文件**:压缩包中通常会包含编译后的`commons-...
- **MyEclipse 8.6**:MyEclipse是一款针对Java EE的集成开发环境,它是Eclipse的扩展,支持包括Java、JSP、JavaScript、SQL、Struts、Spring、Hibernate等多种技术。 - **BlazeDS**:BlazeDS是Adobe提供的一个...
2. **使用场景**:如果你的项目不使用Spring MVC作为控制器,而是使用如Struts2这样的框架,那么`applicationContext.xml`可以单独配置所有Spring相关的bean。但当Spring MVC和`applicationContext.xml`一起使用时,...