struts2 json注解 时 报错:The Result type [json] which is defined in the Result annotation on the clas
2013-06-20 09:09
826 查看
具体报错信息:
class com.pp.action.user.LoginAction 代码:
问题原因:DailyTaskAction类 上 没有 添加
Caused by: The Result type [json] which is defined in the Result annotation on the class [class com.pp.action.user.LoginAction] or determined by the file extension or is the default result type for the PackageConfig of the action, could not be found as a result-type defined for the Struts/XWork package [com.pp.action.user#convention-default#/user] - [unknown location] at org.apache.struts2.convention.DefaultResultMapBuilder.createResultConfig(DefaultResultMapBuilder.java:429) at org.apache.struts2.convention.DefaultResultMapBuilder.createFromAnnotations(DefaultResultMapBuilder.java:401) at org.apache.struts2.convention.DefaultResultMapBuilder.build(DefaultResultMapBuilder.java:202) at org.apache.struts2.convention.PackageBasedActionConfigBuilder.createActionConfig(PackageBasedActionConfigBuilder.java:865) at org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildConfiguration(PackageBasedActionConfigBuilder.java:651) at org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildActionConfigs(PackageBasedActionConfigBuilder.java:336) at org.apache.struts2.convention.ClasspathPackageProvider.loadPackages(ClasspathPackageProvider.java:53) at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:215) at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66) ... 18 more
class com.pp.action.user.LoginAction 代码:
package com.pp.action.Task; import javax.annotation.Resource; import org.apache.struts2.convention.annotation.Action; import org.apache.struts2.convention.annotation.ExceptionMapping; import org.apache.struts2.convention.annotation.ExceptionMappings; import org.apache.struts2.convention.annotation.Namespace; import org.apache.struts2.convention.annotation.ParentPackage; import org.apache.struts2.convention.annotation.Result; import com.opensymphony.xwork2.ActionSupport; import com.pp.dao.task.TaskDaoImpl; @Namespace("/task") @Result(name = "error", location = "/error.jsp") @ExceptionMappings({ @ExceptionMapping(exception = "java.lange.RuntimeException", result = "error") }) public class DaliyTaskAction extends ActionSupport{ private static final long serialVersionUID = 1L; @Resource private TaskDaoImpl taskDao; @Action(value = "login", results = { @Result(name = "success", type = "json"), @Result(name = "fail", type = "json") }) public String addTask()throws Exception{ String result=null; return result; } }
问题原因:DailyTaskAction类 上 没有 添加
@ParentPackage("json-default")解决办法: 加上
@ParentPackage("json-default")注解 即ok
相关文章推荐
- Struts注解开发问题2——The Result type [json] which is defined in the Result annotation on the class
- Caused by: The Result type [json] which is defined in the Result annotation on the class
- Caused by: The Result type [json] which is defined in the Result annotation on the class
- struts2 配置错误There is no result type defined for type 'json'
- struts2 配置错误There is no result type defined for type 'json'
- Struts2 错误:There is no result type defined for type 'json' mapped with name 'success'.
- Struts2 使用ajax访问action,返回json格式数据,提示error:There is no result type defined for type 'json'
- (转)The final local variable xxx cannot be assigned, since it is defined in an enclosing type
- The final local variable xxx cannot be assigned, since it is defined in an enclosing type
- struts2整合json出现no result type defined for type 'json'的解决方法
- The final local variable xxx cannot be assigned, since it is defined in an enclosing type
- SSH搭建遇到的问题---There is no result type defined for type 'json' mapped with name 'success'.
- struts2整合json出现no result type defined for type 'json'的解决方法
- 【转】The final local variable xxx cannot be assigned, since it is defined in an enclosing type
- There is no result type defined for type 'json' mapped with name 'success'.
- Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never diffe
- 错误日志——The result type [org.apache.struts2.json.JSONResult] doesn't have a default param
- struts中使用json,报错There is no result type defined for type 'json' mapped with name 'success'.
- There is no result type defined for type 'json' mapped with name 'success'.
- There is no result type defined for type 'json' mapped with name 'success'.