少主无翼 2015-03-23 11:53 采纳率: 0%
浏览 1514

学习struts convention报错,搞不定,求支援

web.xml:
<!-- struts 配置 -->

struts2

org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter

<filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>


struts.xml:
<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">

<constant name="struts.devMode" value="true" /><!-- 开发模式 -->

<constant name="struts.i18n.encoding" value="UTF-8" /><!-- Web运用编码 -->

<!-- 搜索视图资源的路径 -->
<constant name="struts.convention.result.path" value="/WEB-INF/jsp/" />

<!-- Action类名分隔符 -->
<constant name="struts.convention.action.name.separator" value="_" />

<!-- convention类重加载 -->
<constant name="struts.convention.classes.reload" value="true" />

<!-- Action后缀名 -->
<constant name="struts.convention.action.suffix" value="Action" />

<constant name="struts.action.extension"
                value="action,do,html,htm,php,aspx" /><!-- Action扩展名 -->

<constant name="struts.convention.package.locators"
                    value="web,action" /><!-- 搜索Action资源的包路径 -->

action:
package my.demo.web.action;

import com.opensymphony.xwork2.ActionSupport;

public class HelloWorldAction extends ActionSupport{

        @Override
    public String execute() throws Exception {
        // TODO Auto-generated method stub
        System.out.println("hello world");
        return SUCCESS;
    }

}

报错内容:
Struts Problem Report

Struts has detected an unhandled exception:

Messages:

There is no Action mapped for namespace [/] and action name [hello_world] associated with context path [/DemoConvention].

Stacktraces

There is no Action mapped for namespace [/] and action name [hello_world] associated with context path [/DemoConvention]. - [unknown location]

  • 写回答

1条回答 默认 最新

  • 大河行脚 2015-03-23 13:55
    关注

    There is no Action mapped for namespace [/] and action name [hello_world] associated with context path [/DemoConvention]. - [unknown location]
    HelloWorldAction ,请问你这个action是谁执行的,也就是你在struts.xml里定义的包和action以及result呢?你的问题就出在这里了,你仔细检查一下再将代码改一改。

    如果回答对您有帮助,请采纳

    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料