XIAyuzheng 2013-04-17
if (action instanceof ValidationAware) { ValidationAware validationAwareAction = (ValidationAware) action; if (validationAwareAction.hasErrors()) { if (LOG.isDebugEnabled()) { LOG.debug("Errors on action " + validationAwareAction + ", returning result name 'input'"); } String resultName = inputResultName; if (action instanceof ValidationWorkflowAware) { resultName = ((ValidationWorkflowAware) action).getInputResultName(); } InputConfig annotation = action.getClass().getMethod(invocation.getProxy().getMethod(), EMPTY_CLASS_ARRAY).getAnnotation(InputConfig.class); if (annotation != null) { if (!annotation.methodName().equals("")) { Method method = action.getClass().getMethod(annotation.methodName()); resultName = (String) method.invoke(action); } else { resultName = annotation.resultName(); } } return resultName; } }
<result type="json"> <param name="root">ajaxResult</param> </result>
<result name="success" type="json" > <param name="root">ajaxResult</param> </result> <result name="input" type="json"> <param name="root">ajaxResult</param> </result>
<global-exception-mappings> <exception-mapping exception="java.lang.Exception" result="exception"/> </global-exception-mappings>google:
解决方案:
配置拦截器,删掉default拦截器,然后在自己的拦截器堆栈中加上一些自己需要的default中的拦截器,再在validation拦截器和workflow拦截器之间加上一个拦截器:jsonValidationInterceptor.主要内容:
if (action instanceof ValidationAware) { ValidationAware validationAware = (ValidationAware) action; if (validationAware.hasErrors()) { response.setCharacterEncoding("UTF-8"); response.getWriter().print(buildResponse(validationAware));//自己组装错误信息 response.setContentType("application/json"); return Action.NONE; } }struts.xml配置:
<interceptor-ref name="validation"> <param name="excludeMethods">input,back,cancel</param> </interceptor-ref> <interceptor-ref name="jsonValidationInterceptor"/> <interceptor-ref name="workflow"/>
结束数据方法的参数,该如何定义?-- 集合为自定义实体类中的结合属性,有几个实体类,改变下标就行了。<input id="add" type="button" value="新增visitor&quo
本文实例讲述了php+ ajax 实现的写入数据库操作。分享给大家供大家参考,具体如下:。<input class="tel" type="text" placeholder="请输入您的手机号码&q