关闭

Struts2 DateTimepicker标签 和 java.lang.RuntimeException: Invalid action class configuration that refer

272人阅读 评论(0) 收藏 举报
分类:

异常:

java.lang.RuntimeException: Invalid action class configuration that references an unknown class named [YunWeiAction]
	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:87)
	com.opensymphony.xwork2.DefaultActionInvocation.createResult(DefaultActionInvocation.java:226)
	com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:367)
	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:277)
	com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263)
	org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
	com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:133)
	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
	com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
	com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)
	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243)
	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)
	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:142)
	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:166)
	com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)
	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:190)
	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
	org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:485)
	org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
	org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)

root cause

java.lang.ClassNotFoundException: YunWeiAction
	org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1360)
	org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1206)
	org.apache.struts2.util.ClassLoaderUtils.loadClass(ClassLoaderUtils.java:111)
	org.apache.struts2.convention.ConventionsServiceImpl.determineResultPath(ConventionsServiceImpl.java:98)
	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:87)
	com.opensymphony.xwork2.DefaultActionInvocation.createResult(DefaultActionInvocation.java:226)
	com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:367)
	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:277)
	com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263)
	org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
	com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:133)
	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
	com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
	com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)
	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243)
	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)
	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:142)
	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:166)
	com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)
	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:190)
	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
	com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
	org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:485)
	org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
	org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)


大致有三种可能原因:
(1)这个Action类的确是不存在,或者是在struts.xml中配置错了。  http://see-sea007.blog.163.com/blog/static/59008062201212951911913/ 
(2)没有合适的result name。如果result name错了的话,也有可能报这个错。 http://apps.hi.baidu.com/share/detail/57378863 
(3)JSP页面的错误。 http://blog.163.com/ztxz_179/blog/static/105205995201221711561637/ 

我是第三种!坑爹啊!下面的方式使用的checkbox标签错了!我不知道为什么!
<s:checkbox name="groupUser.oilele" fieldValue="1"
    value="groupUser.oilele" label="断油断电权限" />
<s:checkbox name="groupUser.modify" fieldValue="1"
    value="groupUser.modify" label="修改信息权限" />
<s:checkbox name="groupUser.export" fieldValue="1"
    value="groupUser.export" label="导出数据权限" />
(4)第四种可能就是Action错了。我出现了一次,是类型问题,我估计上面的错误还是类型问题!比如,前台界面中一个 <input type="text" value="2012-01-01" name="searchDate" />的
输入框,如果是让它对应后台Action中的Date类型的searchDate,那么可能就会出现这个错误!
我的解决办法是将Action中的Date改成String类型的,至于String和Date类型之间的转换我就使用DateFormat。不过,貌似还可以自定义类型转换器达到这个目的,可以查看书《深入浅出Struts2》,
里面有介绍。
例子:

前台JSP:
<input name="searchStartDate" type="text" class="dateinput" value="<s:property value="searchStartDate" />" /> - <input name="searchEndDate" type="text" class="dateinput" value="<s:property value="searchEndDate" />" />

 

后台Action:

复制代码
    /**
     * 日志管理
     * @return
     */
    public String logManager() {
        Calendar calendar = Calendar.getInstance();
        calendar.roll(Calendar.DATE, 1);//到下一天的凌晨
        Date endDate = calendar.getTime();
        calendar.roll(Calendar.DATE, -3);// 前三天的凌晨
        Date startDate = calendar.getTime();
        findLogList(startDate,endDate);
        searchEndDate = dateFormat.format(endDate);
        searchStartDate = dateFormat.format(startDate);
        return SUCCESS;
    }

    /**
     * 日志搜索
     * @return
     */
    public String logSearch() {
        // 转型 String->Date
        System.out.println(searchDate);
        System.out.println(searchDate.getDate());
        try {
            findLogList(dateFormat.parse(searchStartDate),dateFormat.parse(searchEndDate));
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        page = "YunWei_logManager";
        return TARGET;
    }

    // 内部方法,得到指定时间之内的日志列表
    private void findLogList(Date startDate,Date endDate) {
        System.out.println(searchStartDate);
        System.out.println(searchEndDate);
        // 得到总记录数
        total = logService.getCountByTimeBetween(startDate,endDate);
        // 得到总页数
        if (total % PAGESIZE == 0) {
            pages = total / PAGESIZE;
        } else {
            pages = total / PAGESIZE + 1;
        }
        // 得到当前的页索引
        if (pageIndex < 1)
            pageIndex = 1;
        if (pageIndex > pages)// 暂时不判断
            pageIndex = pages;
        logList = logService.findByTimeBetween(startDate, endDate, (pageIndex - 1) * PAGESIZE, PAGESIZE);
    }
复制代码

 

这种情况下的更好的解决办法是使用struts 2的datetimepicker标签:http://www.mkyong.com/struts2/struts-2-datetimepicker-example/

例子:记得将 struts-dojo-plugin.jar 包放到WEB-INF/lib下!

复制代码
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sx" uri="/struts-dojo-tags" %>
<html>
<head>
<sx:head />
</head>
<body>
<sx:datetimepicker name="date2" label="Format (dd-MMM-yyyy)" 
displayFormat="dd-MMM-yyyy" value="%{'2010-01-01'}"/>
复制代码

 

Action中定义为Date类型,传过来的值得到的也是Date类型!

前台JSP:

<td><sx:datetimepicker name="searchStartDate"
            displayFormat="yyyy-MM-dd" value="%{searchStartDate}" /> —— <sx:datetimepicker name="searchEndDate"
            displayFormat="yyyy-MM-dd" value="%{searchEndDate}" /> 
            </td>

 

后台Action:

复制代码
    /**
     * 日志管理
     * 
     * @return
     */
    public String logManager() {
        Calendar calendar = Calendar.getInstance();
        calendar.roll(Calendar.DATE, 1);// 到下一天的凌晨
        searchEndDate = calendar.getTime();
        calendar.roll(Calendar.DATE, -3);// 前三天的凌晨
        searchStartDate = calendar.getTime();
        findLogList(searchStartDate, searchEndDate);
        return SUCCESS;
    }

    /**
     * 日志搜索
     * 
     * @return
     */
    public String logSearch() {
        // 转型 String->Date
        findLogList(searchStartDate, searchEndDate);
        page = "YunWei_logManager";
        return TARGET;
    }

    // 内部方法,得到指定时间之内的日志列表
    private void findLogList(Date startDate, Date endDate) {
        System.out.println(searchStartDate);
        System.out.println(searchEndDate);
        // 得到总记录数
        total = logService.getCountByTimeBetween(startDate, endDate);
        // 得到总页数
        if (total % PAGESIZE == 0) {
            pages = total / PAGESIZE;
        } else {
            pages = total / PAGESIZE + 1;
        }
        // 得到当前的页索引
        if (pageIndex < 1)
            pageIndex = 1;
        if (pageIndex > pages)// 暂时不判断
            pageIndex = pages;
        logList = logService.findByTimeBetween(startDate, endDate, (pageIndex - 1) * PAGESIZE, PAGESIZE);
    }
复制代码

 

这样子,代码简洁多了!

 

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:8289次
    • 积分:125
    • 等级:
    • 排名:千里之外
    • 原创:0篇
    • 转载:31篇
    • 译文:0篇
    • 评论:0条
    文章存档