少主无翼 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 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100