少主无翼 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呢?你的问题就出在这里了,你仔细检查一下再将代码改一改。

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

    评论

报告相同问题?

悬赏问题

  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败
  • ¥15 MapReduce实现倒排索引失败
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型