<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 ...
随机推荐
- Mongoose的分页功能
来自: https://github.com/edwardhotchkiss/mongoose-paginate 拷贝如下: Note: This plugin will only work wi ...
- [Docker] Getting Started with Container Networks
It is possible to group containers into a network and we can create multi networks so that container ...
- 理解linux sed命令
理解linux sed命令(2010-02-27 18:21:20) 标签:linuxshellsed替换 分类:革命本钱 1. Sed简介sed是一种在线编辑器,它一次处理一行内容.处理时,把当 前 ...
- Linux环境下网络编程杂谈《转》
今天我们说说“Pre-网络编程”.内容比较杂,但都是在做网络应用程序开发过程中经常要遇到的问题. 一.大端.小端和网络字节序 小端字节序:little-endian,将低字节存放在内存的起始地址: 大 ...
- Android应用Preference相关及源代码浅析(SharePreferences篇)
1 前言 在我们开发Android过程中数据的存储会有非常多种解决方式,譬如常见的文件存储.数据库存储.网络云存储等,可是Android系统为咱们提供了更加方便的一种数据存储方式.那就是SharePr ...
- SuperMap iDesktop之导入数据
SuperMap作为一个平台软件有自己的数据格式,现要将ESRI的SHP数据导入到SuperMap的udb数据库中,可以完成导入,但也不得不说几点问题. 下面是ArcGIS中批量导入SHP的操作界面. ...
- Pig拒绝连接错误
运行Pig时出现错误: Pig Stack Trace --------------- ERROR 1066: Unable to open iterator for alias visit. Bac ...
- Searching for equivalent of FileNotFoundError in Python 2
I created a class named Options. It works fine but not not with Python 2. And I want it to work on b ...
- Influxdb数据压缩
环境: CentOS6.5_x64InfluxDB版本:1.1.0 数据压缩可以参考: https://docs.influxdata.com/influxdb/v1.1/concepts/stora ...
- Page Visibility实现焦点丢失提醒
0.前言 HTML5 Page Visibility API是一个很实用的特性.当页面对用户不可见时,暂停播放页面中的视频.动画.声音.以及其它耗费内存的操作,等用户回来时.再继续这些操作. 当然,最 ...