Struts2异常:HTTP Status 404 - There is no Action mapped for action name addBook.
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.的更多相关文章
- Struts2异常:HTTP Status 404 - /Struts2/book/addBook.action
HTTP Status 404 - /Struts2/book/addBook.action 如果在Struts2的框架中访问路径出现了这个错误,可能存在的原因有如下的两个: 1. 路径写错,也就是a ...
- 68. 使用thymeleaf报异常:Not Found, status=404【从零开始学Spring Boot】
[从零开始学习Spirng Boot-常见异常汇总] 我们按照正常的流程编码好了 controller访问访问方法/hello,对应的是/templates/hello.html文件,但是在页面中还是 ...
- TOMCAT报错:HTTP Status 404 -
构建struts2工程师,tomcat报错: HTTP Status 404 - type Status report message description The requested resour ...
- JavaEE SSH框架整合(三) struts2 异常、http错误状态码处理
struts2的action可能出现訪问不到,或action报异常等情况,所以须要作一些处理,给用户一个友好的印象. 1. 异常处理 result声明在action中 <action name ...
- 在IE浏览器输入测试servlet程序报:HTTP Status 404(The requested resource is not available)错
一.HTTP Status 404(The requested resource is not available)异常主要是路径错误或拼写错误造成的,请按以下步骤逐一排查: 1.未部署Web应用 2 ...
- 报错: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 ...
- struts2 <s:iterator> status属性
struts2 <s:iterator> status属性 转载▼ iterator标签主要是用于迭代输出集合元素,如list set map 数组等,在使用标签的时候有三个属性值得我 ...
- Jsp——http status 404 问题
今天学习Jspapplication内置对象的时候突然碰到了一个问题——http status 404 发生了什么? 提示The requested resource is not available ...
- 在写ssh项目时浏览器页面出现http status 404 – not found
HTTP Status 404 - /streetManager/index.jsp type Status report message /streetManager/index.jsp descr ...
随机推荐
- 算法学习 howto
入门: The Most Important Algorithms http://www.risc.jku.at/people/ckoutsch/stuff/e_algorithms.html Alg ...
- java并发学习--第八章 JDK 8 中线程优化的新特性
一.新增原子类LongAdder LongAdder是JDK8中AtomicLong的增强工具类,它与AtomicLong最大的不同就是:在多线程场景下,LongAdder中对单一的变量进行拆分成多个 ...
- dd命令注意:dd:unrecognized operand 'if'
如果是 idd if=boot.bin 在等号两边不要有空格
- Spring Security初识
Spring Security与Spring Boot集成 添加依赖: <dependency> <groupId>org.springframework.boot</g ...
- HDU-6278-Jsut$h$-index(主席树)
链接: https://vjudge.net/problem/HDU-6278 题意: The h-index of an author is the largest h where he has a ...
- Python---Tkinter---贪吃蛇
# 项目分析: - 构成: - 蛇 Snake - 食物 Food - 世界 World - 蛇和食物属于整个世界 class World: self.snake self.food ------- ...
- 决策树剪枝算法-悲观剪枝算法(PEP)
前言 在机器学习经典算法中,决策树算法的重要性想必大家都是知道的.不管是ID3算法还是比如C4.5算法等等,都面临一个问题,就是通过直接生成的完全决策树对于训练样本来说是“过度拟合”的,说白了是太精确 ...
- 寻找的常用webstorm快捷键
1. 必备快捷键 Ctrl+/:注释当前行 Ctrl+Shift+/:当前位置插入注释 Ctrl+Alt+/:块注释,并Focus到首行,写注释说明用的 Ctrl+Shift+A:选择当前标签前后,修 ...
- nasm不是内部或外部命令
使用nasm编译汇编的源文件: nasm -f bin first.asm -o first.bin 报错:nasm不是内部或外部命令,这种错误一看就知道,是没有配置环境变量. 点开后,选择path, ...
- 配置 app.js 文件
pp.js 中存放全局的 JavaScript 逻辑. 示例: App({ onLaunch: function () { console.log('SWAN launch'); }, onShow: ...