<welcome-file>index.action</welcome-file>直接设置action,404和struts2中的解决方案
这几天的项目页面的访问全部改为.action访问,在修改首页时遇到了问题。将web.xml文件中<welcome-file>index.action</welcome-file>修改成这样,访问首页时报404错误,也就是说文件找不到。上网查了有两种解决方法。
方法一、在WebRoot下新建一个index.action空文件,这个方法简单实用,强烈推荐。
方法二、因为 welcome-file 必须是实际存在的文件,不能是action或者servlet路径你可以设置一个 比如
<welcome-file>goindex.jsp</welcome-file>,然后 goindex.jsp 写
<jsp:forward page="index.action" />
就行了。意思就是借助一个jsp页面来转发请求进入action。
方法三:在index.html中使用META重定向。
操作:<META
HTTP-EQUIV="Refresh" CONTENT="0;URL=max/HelloWorld.action">
其中,
content="1
是时间控制,表示1秒后自动跳转到要跳转的页面.
content="0
表示打开该页后立即跳转到你要跳转的页面.
url 是要跳转的路径
——————————————————————————————————————————————
在struts2中还很特别:
原因:
因为struts2采用过滤器的方式处理请求,默认情况时监控url地址的变化
必须如下操作:
第一步:
web.xml中修改
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern
>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
第二步:
web.xml中添加
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
第三步:
首页跳转语句
index.jsp内容如下:
<jsp:forward
page="HelloWorld.action"></jsp:forward>
或者采用方法三!!!
来自:http://blog.sina.com.cn/s/blog_4b5bc0110100yrn2.html
<welcome-file>index.action</welcome-file>直接设置action,404和struts2中的解决方案的更多相关文章
- struts2中<welcome-file>index.action</welcome-file>直接设置action,404的解决方案
这几天的项目页面的访问全部改为.action访问,在修改首页时遇到了问题.将web.xml文件中<welcome-file>index.action</welcome-file> ...
- No result defined for action com.java.test.Action.HelloAction and result index
Struts中配置action访问出错: Struts Problem Report Struts has detected an unhandled exception: Messages: No ...
- android ReactNative之Cannot find entry file index.android.js in any of the roots
android ReactNative之Cannot find entry file index.android.js in any of the roots 2018年04月02日 14:53:12 ...
- Signing package index... Cannot open file '/home/jello/openwrt/key-build' for reading
一.环境 发行版:Ubuntu 18.04.1 LTS 代号:bionic 内核版本:4.15.0-30-generic 二.背景 在编译Openwrt/LEDE时出现以下错误,进而自动终止了编译: ...
- SyntaxError: Non-ASCII character '\xe5' in file index.py on line 6, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
python入门,hhh 在慕课网上学习python入门,编写汉诺塔的递归调用时,代码正确.但是加上注释后编译不通过 报如下错误: SyntaxError: Non-ASCII character , ...
- 【转】Caused by: Action class [com.struts.action.xxxAction] not found 解决方法
刚学习Struts,自己写了个简单程序,一启动tomcat就报错,但是我按着ctrl点击struts.xml中com.struts.action.LoginAction也能定位到LoginAction ...
- [原创]java WEB学习笔记55:Struts2学习之路---详解struts2 中 Action,如何访问web 资源,解耦方式(使用 ActionContext,实现 XxxAware 接口),耦合方式(通过ServletActionContext,通过实现 ServletRequestAware, ServletContextAware 等接口的方式)
本博客的目的:①总结自己的学习过程,相当于学习笔记 ②将自己的经验分享给大家,相互学习,互相交流,不可商用 内容难免出现问题,欢迎指正,交流,探讨,可以留言,也可以通过以下方式联系. 本人互联网技术爱 ...
- 关于Struts2中 Action 配置method的解读
为Action配置method属性: 将Action类中的每一个处理方法都定义成一个逻辑Action方法. <!DOCTYPE struts PUBLIC "-//Apache Sof ...
- Struts2中jsp前台传值到action后台的三种方式以及valueStack的使用
struts2中的Action接收表单传递过来的参数有3种方法: 如,登陆表单login.jsp: <form action="login" method="pos ...
随机推荐
- 如何实现json字符串和 BsonDocument的互相转换
String to BsonDocument string json = "{ 'foo' : 'bar' }"; MongoDB.Bson.BsonDocument docume ...
- Mongoose Connection best practice
There is often quite a lot of confusion about how best to set up a database connection with Mongoose ...
- Node js : Best way to define entity class
If you start to use a DB like mongo, you might be better off creating objects with mongoose but th ...
- mac切换root
方法一: sudo -i sudo su或是su. 转自:http://blog.csdn.net/duanyipeng/article/details/8621967
- 解压版mysql的配置与使用
1.在环境变量path中添加mysql的bin目录路径,例如 D:\Program Files\MySQL\mysql\bin 2.修改mysql目录下的my-default.ini文件 # 设置my ...
- Google想出了一个决定人员晋升的算法,然后就没有然后了......
Google 有点跑偏了,逗死我了~实践一下也好~ Prasad Setty 是 Google People Analytics 团队的副总裁.7 年前 Google 成立的这支团队的职责是收集和利用 ...
- 微信小程序 - 时间轴(组件)
更新日期: 2019/3/6:首次发布 2019/3/7:增加content和date自定义(具体使用看示例) 时间轴 参数: 1. data(新闻列表数据)- 2019/3/6 2. content ...
- Word转PDF非常好用的软件——pdfFactory Pro
pfdFactory Pro把word转为pdf的操作步骤: 1.打开将要转换的word的文档: 2.文件--->打印: 弹出如下对话框: 单击确定后弹出:
- SQL Server临时表
[]SQL Server临时表]()https://docs.microsoft.com/zh-cn/sql/relational-databases/tables/temporal-tables)
- python操作Excel的几种方式
Python对Excel的读写主要有xlrd.xlwt.xlutils.openpyxl.xlsxwriter几种. 1.xlrd主要是用来读取excel文件 import xlrd workbook ...