具体报错信息:

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


posted on 2013-06-20 09:09  wyang0126  阅读(1439)  评论(0编辑  收藏  举报