这几天的项目页面的访问全部改为.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. docker swarm join如何获取token

    在运行docker swarm join的时候需要一个token参数,如何知道这个参数那? [答案] Join as a worker node To retrieve the join comman ...

  2. DOM对象操作html元素1

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...

  3. Direct2D教程IV——笔刷(Brush)对象

    目前博客园中成系列的Direct2D的教程有 1.万一的 Direct2D 系列,用的是Delphi 2009 2.zdd的 Direct2D 系列,用的是VS中的C++ 3.本文所在的 Direct ...

  4. 【Python】安装geopy

    C:\Users\horn1\Desktop\python\49-geo>pip install geopy Collecting geopy Retrying (Retry(total=4, ...

  5. file: /SourceCache/IOKitUser_Sim/IOKitUser-920.1.11/hid.subproj/IOHIDEventQueue.c, line: 512

    //修改main.m 文件. typedef int (*PYStdWriter)(void *, const char *, int); static PYStdWriter _oldStdWrit ...

  6. VMware vSphere can virtualize itself + 64-bit nested guests

    Running VMware ESXi inside a virtual machine is a great way to experiment with different configurati ...

  7. C++ 第九课 标准c数学函数

    abs() 求绝对值 acos() 求反余弦 asin() 求反正弦 atan() 求反正切 atan2() 求反正切,按符号判定象限 ceil() 求不小于某值的最小整数 (求上界) cos() 求 ...

  8. angularjs component

    Component https://docs.angularjs.org/guide/component component本质上就是directive. This is a shorthand fo ...

  9. Java Netty (1)

    Netty是由JBOSS提供的一个java开源框架,本质上也是NIO,是对NIO的封装,比NIO更加高级,功能更加强大.可以说发展的路线是IO->NIO->Netty. ServerBoo ...

  10. 从头认识Spring-1.14 SpEl表达式(1)-简单介绍与嵌入值

    这一章节我们来讨论一下SpEl表达式的简单介绍与嵌入值. 1.SpEl表达式简单介绍 Spring Excpression Language (SpEL)语言支持在执行时操作和查询对象 事实上就是在执 ...