<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 ...
随机推荐
- logback-kafka-appender
logback 日志写入kafka队列 logback-kafka-appender Logback incompatibility Warning Due to a bug in logback-c ...
- ccc如何在一台windows主机上搭建mysql主从复制
参考:http://www.cnblogs.com/wzjbk/p/6266899.htmlc 进入mysql: 进入到mysql的bin目录下才可以输入 mysql -hlocalhost -uro ...
- SQL 之 查询操作重复记录
有时,我们的数据表中会存在一些冗余数据,这就要求我们查询并操作这些冗余数据. 一.查询表中重复记录 例如,查找重复记录是根据单个字段(peopleId)来判断 SELECT * FROM Tpeopl ...
- vue build后运行错误
events.js:141 throw er; // Unhandled 'error' event 这个是端口占用的问题 $ http-server dist events.js:141 throw ...
- CDH的安装和设置
采用伪分布模式安装和设置CDH,前提是已经安装了Java和SSH. 1. 下载hadoop-2.6.0-cdh5.9.0,复制到/opt/下,再解压: 2. 进入/opt/hadoop-2.6.0-c ...
- markdown 常用语法格式
1.示例1 http://mahua.jser.me/ 2.示例2 https://www.zybuluo.com/mdeditor?url=https%3A%2F%2Fwww.zybuluo.com ...
- SpringMVC学习笔记五:使用converter进行参数数据转换
转载请注明原文地址:http://www.cnblogs.com/ygj0930/p/6832898.html 一:SpringMVC数据绑定机制 1:request到达SpringMVC框架时,框 ...
- Lucene解析 - 基本概念
Elasticsearch 权威指南中文版 https://www.elastic.co/guide/cn/elasticsearch/guide/cn/index.html 对于跳跃表,我们看 ...
- java 浮点运算
CreateTime--2017年12月1日11:35:00 Author:Marydon java 浮点类型(float.double)间的运算工具类 /** * 进行BigDecimal对象的 ...
- 配置Jenkins的slave节点的详细步骤适合windows等其他平台
@ 新建一个slave节点在Jenkins服务器上 1,进入Jenkins的主界面,进入"Manage Jenkins" 页面: 2,点击如下图中的"Manage N ...