HTTP Status 404 - There is no Action mapped for action name addBook.

  

  在地址栏进行访问的时候,出现了这个错误信息,导致出现此异常的原因可能有如下的三个原因:

    1. 可能是struts.xml文件的名称或者位置写错。

    2. 可能是struts.xml文件的内容错误。

    3. 可能是因为struts.xml文件按照分模块的方式进行编辑,没有将模块下的xml文件引入到struts的核心配置文件struts.xml中(我的异常因为这个原因)

    

正确的struts.xml模板:

  1. 分模块struts.xml和book.xml(struts.xml核心配置文件,book.xml模块配置文件。只需要将book.xml引入到struts.xml)

book.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">
<struts>
<package name="bookaction" extends="struts-default" namespace="/book">
<action name="addBook" class="cn.geore.bookaction.BookAction" method="addBook">
<result name="success">/jsps/one/addBook.jsp</result>
</action> <action name="updateBook" class="cn.geore.bookaction.BookAction" method="updateBook">
<result name="success">/jsps/one/updateBook.jsp</result>
</action>
</package>
</struts>

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">
<struts>
<constant name="struts.i18n.encoding" value="UTF-8"></constant>
<!-- 引入外部的Struts模块的配置文件 -->
<!-- <include file="cn/geore/action/one.xml"></include> -->
<include file="cn/geore/bookaction/book.xml"></include>
</struts>

2. 不分模块的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">
<struts>
<package name="bookaction" extends="struts-default" namespace="/book">
<action name="addBook" class="cn.geore.bookaction.BookAction" method="addBook">
<result name="success">/jsps/one/addBook.jsp</result>
</action> <action name="updateBook" class="cn.geore.bookaction.BookAction" method="updateBook">
<result name="success">/jsps/one/updateBook.jsp</result>
</action>
</package>
</struts>

Struts2异常:HTTP Status 404 - There is no Action mapped for action name addBook.的更多相关文章

  1. Struts2异常:HTTP Status 404 - /Struts2/book/addBook.action

    HTTP Status 404 - /Struts2/book/addBook.action 如果在Struts2的框架中访问路径出现了这个错误,可能存在的原因有如下的两个: 1. 路径写错,也就是a ...

  2. 68. 使用thymeleaf报异常:Not Found, status=404【从零开始学Spring Boot】

    [从零开始学习Spirng Boot-常见异常汇总] 我们按照正常的流程编码好了 controller访问访问方法/hello,对应的是/templates/hello.html文件,但是在页面中还是 ...

  3. TOMCAT报错:HTTP Status 404 -

    构建struts2工程师,tomcat报错: HTTP Status 404 - type Status report message description The requested resour ...

  4. JavaEE SSH框架整合(三) struts2 异常、http错误状态码处理

    struts2的action可能出现訪问不到,或action报异常等情况,所以须要作一些处理,给用户一个友好的印象. 1. 异常处理  result声明在action中 <action name ...

  5. 在IE浏览器输入测试servlet程序报:HTTP Status 404(The requested resource is not available)错

    一.HTTP Status 404(The requested resource is not available)异常主要是路径错误或拼写错误造成的,请按以下步骤逐一排查: 1.未部署Web应用 2 ...

  6. 报错:HTTP Status 404 - There is no Action mapped for namespace [/] and action name [product-save] associated with context path [/20161101-struts2-2].

    运行:index.jsp---->input.jsp----->details.jsp,但是在input.jsp到details.jsp的时候报错误. 异常如下: 严重: Could no ...

  7. struts2 <s:iterator> status属性

    struts2 <s:iterator> status属性 转载▼   iterator标签主要是用于迭代输出集合元素,如list set map 数组等,在使用标签的时候有三个属性值得我 ...

  8. Jsp——http status 404 问题

    今天学习Jspapplication内置对象的时候突然碰到了一个问题——http status 404 发生了什么? 提示The requested resource is not available ...

  9. 在写ssh项目时浏览器页面出现http status 404 – not found

    HTTP Status 404 - /streetManager/index.jsp type Status report message /streetManager/index.jsp descr ...

随机推荐

  1. 【学习】016 MySQL数据库优化

    MySQL如何优化 表的设计合理化(符合3NF) 添加适当索引(index) [四种: 普通索引.主键索引.唯一索引unique.全文索引] SQL语句优化 分表技术(水平分割.垂直分割) 读写[写: ...

  2. CSP-S 赛前模板复习

    快读模板 这个连算法都算不上... inline int read() { int x=0,f=1; char ch=getchar(); while(ch<'0' || ch>'9') ...

  3. Halcon WPF C#采集图像区域灰度值

    源码下载地址:https://github.com/lizhiqiang0204/ImageGray.git Halcon代码如下: *读取图片,转换成灰度图片 read_image (Image1, ...

  4. Flutter-Radio單選框

    Container( child: Radio<String>( value: "男", activeColor: Colors.red,//激活時的顏色 groupV ...

  5. 解决扫码枪输入input时受中文输入法的影响

    <html><head> <meta content="text/html; charset=UTF-8" http-equiv="Cont ...

  6. git push -u origin master和git push <远程主机名> <本地分支名>:<远程分支名>作用

    git push git push命令用于将本地分支的更新,推送到远程主机.它的格式与git pull命令相仿. $ git push <远程主机名> <本地分支名>:< ...

  7. 【leetcode】848. Shifting Letters

    题目如下: 解题思路:本题首先要很快速的计算出任意一个字符shift后会变成哪个字符,其实也很简单,让shift = shift % 26,接下来再做计算.第二部是求出每个字符要shift的次数.可以 ...

  8. Linux文件及目录查找

    Linux文件及目录查找 一which——显示命令的完整路径 [root@centos71 ~]# which ls alias ls='ls --color=auto' /usr/bin/ls [r ...

  9. CSS盒子模型中的Padding属性

    CSS padding 属性 CSS padding 属性定义元素边框与元素内容之间的空白区域,不可见.如果想调整盒子的大小可以调整内容区,内边距,边框. CSS padding 属性定义元素的内边距 ...

  10. Comet OJ - Contest #6 C 一道树题 数学 + 推导

    Code: #include <bits/stdc++.h> #define setIO(s) freopen(s".in","r",stdin) ...