这几天的项目页面的访问全部改为.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中的解决方案的更多相关文章

  1. struts2中<welcome-file>index.action</welcome-file>直接设置action,404的解决方案

    这几天的项目页面的访问全部改为.action访问,在修改首页时遇到了问题.将web.xml文件中<welcome-file>index.action</welcome-file> ...

  2. 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 ...

  3. 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 ...

  4. 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时出现以下错误,进而自动终止了编译: ...

  5. 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 , ...

  6. 【转】Caused by: Action class [com.struts.action.xxxAction] not found 解决方法

    刚学习Struts,自己写了个简单程序,一启动tomcat就报错,但是我按着ctrl点击struts.xml中com.struts.action.LoginAction也能定位到LoginAction ...

  7. [原创]java WEB学习笔记55:Struts2学习之路---详解struts2 中 Action,如何访问web 资源,解耦方式(使用 ActionContext,实现 XxxAware 接口),耦合方式(通过ServletActionContext,通过实现 ServletRequestAware, ServletContextAware 等接口的方式)

    本博客的目的:①总结自己的学习过程,相当于学习笔记 ②将自己的经验分享给大家,相互学习,互相交流,不可商用 内容难免出现问题,欢迎指正,交流,探讨,可以留言,也可以通过以下方式联系. 本人互联网技术爱 ...

  8. 关于Struts2中 Action 配置method的解读

    为Action配置method属性: 将Action类中的每一个处理方法都定义成一个逻辑Action方法. <!DOCTYPE struts PUBLIC "-//Apache Sof ...

  9. Struts2中jsp前台传值到action后台的三种方式以及valueStack的使用

    struts2中的Action接收表单传递过来的参数有3种方法: 如,登陆表单login.jsp: <form action="login" method="pos ...

随机推荐

  1. mongoDB开发规范

    mongoDB库的设计 mongodb数据库命名规范:db_xxxx 禁止使用任何 " _ "(下划线)外的特殊字符 禁止使用数字打头的库名 数据库名最多为 64字符 mongoD ...

  2. [Algorithm] Count occurrences of a number in a sorted array with duplicates using Binary Search

    Let's say we are going to find out number of occurrences of a number in a sorted array using binary ...

  3. (纪录片)鸟瞰中国 China from Above

    简介: 类型: 纪录片官方网站: natgeotv.com/uk/china-from-above制片国家/地区: 美国语言: 英语集数: 2单集片长: 44分钟IMDb链接: tt4872012 主 ...

  4. clearfix 兼容IE6/IE7,解决ie6/ie7下多出一行的问题,bootstrap的clearfix的bug

    .clearfix:before, .clearfix:after { content: "."; display: block; height: ; overflow: hidd ...

  5. docker toolbox在win7下的安装

    1.下载安装docker toolbox docker toolbox的下载地址: http://mirrors.aliyun.com/docker-toolbox/windows/docker-to ...

  6. gdbserver 移植与多线程调试

    在嵌入式linux平台使用gdb调试进行远程调试需要安装gdbserver,gdbserver工作在目标板上,通过串口或者网线与主机上的gdb互联实现远程调试. Gdbserver需要根据不同的嵌入式 ...

  7. Linux中磁盘分区、格式化、挂载等管理

    1. 添加磁盘,查看磁盘状况 [root@db1 /]# fdisk -l Disk /dev/sda: bytes heads, sectors/track, cylinders Units = c ...

  8. 016-Go Iris Restful测试

    1:data/data.go package data import( "fmt" "database/sql" _"github.com/lib/p ...

  9. linux cp 命令详解

    /home/lee#cp --help 用法:cp [选项]... 来源 目的地 或:cp [选项]... 来源... 目录 或:cp [选项]... --target-directory=目录 来源 ...

  10. Exchanger的使用

    两个线程可以交换对象的同步点.每个线程都在进入 exchange 方法时给出某个对象,并接受其他线程返回时给出的对象. 用于实现两个人之间的数据交换,每个人在完成一定的事务后想与对方交换数据,第一个先 ...