li921228527
li921228527
采纳率0%
2017-07-28 06:38 阅读 827

SSH框架的提交按钮无法执行提问

HTTP Status 404 - There is no Action mapped for namespace / and action name save.

type Status report

message There is no Action mapped for namespace / and action name save.

description The requested resource is not available.

struts文件
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">


<!-- 将struts2的ui模式设置为simple -->


<!-- =================基础设置========================================== -->
<package name="login" extends="struts-default" namespace="/">
    <global-results>
        <result name="error">/errors/errorinfo.jsp</result>
        <result name="auth">/errors/auth.jsp</result>
        <result name="uploaderror">/errors/uploaderror.jsp</result>
    </global-results>
    <!-- 登录列表 -->
    <action name="login" class="com.heb.login.action.LoginAction"   method="login">
        <result name="success"  type="redirect">welcome.html</result>   
    </action>       
    <!-- 新闻动态 -->
    <action name="save" class="com.heb.companyNews.action.companyNewsAction"    method="save">
        <result name="success" >/companyNews/news-list.html</result>    
    </action>

</package>

save方法
public String save() {
try {
if (null==news.getId()) {

newsDAO.save(news);
}

return SUCCESS;
} catch (Exception e) {
// TODO: handle exception
return ERROR;
}
}

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

2条回答 默认 最新

  • sun1021873926 夕阳雨晴 2017-07-28 06:45
    点赞 评论 复制链接分享
  • qq_32903893 菜鸡小石头 2017-07-28 06:50

    1,struts.xml文件名拼写错误
    2,struts.xml文件路径错误
    3,struts.xml文件内容错误。注意配置的action是否正确
    信息太少,估计就是配置文件错误了

    点赞 评论 复制链接分享

相关推荐