论坛首页 Java企业应用论坛

刚学的struts2,动态方法调用报错

浏览 3038 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2014-06-26  
刚学的struts2,动态方法调用老是报错
错误:Messages:
There is no Action mapped for namespace [/] and action name [newsdoGetAllNews] associated with context path [].

<struts>
    <!--开发模式下使用,可以打印出跟详细的错误-->
    <constant name="struts.devMode" value="true"/>
    <!--设置struts2编码-->
    <constant name="struts.i18n.encoding" value="UTF-8"/>
    <!--是否支持动态方法-->
    <constant name="struts.enable.DynamicMethodInvocation" value="true"/>

    <package name="news" extends="struts-default" namespace="/news">
        <action name="news*" class="cn.Action.NewsAction" method="{1}">
            <result name="list">/list.jsp</result>
        </action>

    </package>

</struts>


public class NewsAction extends ActionSupport {
    public String GetAllNews() throws  Exception{
        News news = new News();
        System.out.print(news.getNewsType().getNewsTypeName());
        NewsService newsService = new NewsServiceimpl();
        newsService.getAll(news.getNewsType().getNewsTypeName());
        return "list";
    }
}

<s:a href="newsGetAllNews?news.newsType.newsTypeName=军事">军事</s:a>
   发表时间:2014-06-27  
namespace="/news",可是你的路径是/开始的。
1. url替换为news/newsGetAllNews?xxxxx
或者是
2. namespace换成/
0 请登录后投票
   发表时间:2014-06-27  
这学习能力让人担忧啊!
0 请登录后投票
   发表时间:2014-06-27  
大哥,你真牛,看来你还没了解Struts2,  这样对后面的学习有点困难;
0 请登录后投票
   发表时间:2014-07-01  
freezingsky 写道
这学习能力让人担忧啊!

你不装那13你会死啊?
0 请登录后投票
   发表时间:2014-07-01  
lijian97593685 写道
大哥,你真牛,看来你还没了解Struts2,  这样对后面的学习有点困难;

你不装那13你会死啊?
0 请登录后投票
   发表时间:2014-07-01  
yuhui0531 写道
freezingsky 写道
这学习能力让人担忧啊!

你不装那13你会死啊?

再过两年,你再来看你这个帖子,会有新的想法!祝你好运!
0 请登录后投票
   发表时间:2014-07-25  
freezingsky 写道
yuhui0531 写道
freezingsky 写道
这学习能力让人担忧啊!

你不装那13你会死啊?

再过两年,你再来看你这个帖子,会有新的想法!祝你好运!


装,继续装!
0 请登录后投票
   发表时间:2014-07-26  
yuhui0531 写道
freezingsky 写道
yuhui0531 写道
freezingsky 写道
这学习能力让人担忧啊!

你不装那13你会死啊?

再过两年,你再来看你这个帖子,会有新的想法!祝你好运!


装,继续装!

难道有说错吗?照着例子抄,都没能抄对,还能说啥!
0 请登录后投票
论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics