struts2设置index.action为主页(另:web.xml编辑卡死问题解决)
本来是弄拦截器的问题,结果弄主页的时候,还是发现了问题。
公司网站的项目里面,是用index.action作为主页的,访问WEB-INF里面的html文件。可是我设置的却不成功,追根到底,一个原因,struts2比较特殊,struts.xml里面必须多配置一个request和response。
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_9" version="3.0" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_3_0.xsd"> <display-name>Struts Blank</display-name> <filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter> <filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern> <dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping> <welcome-file-list>
<welcome-file>index.action</welcome-file>
</welcome-file-list> </web-app>
这样就可以轻松使用index.action作为主页。
另外这样配置后,也可以用jsp里面加forward来跳转到index.action作为主页。也可以用html里面加一个<meta>标签刷新跳转到主页action里面。
不经过request和response,只能用html加<meta>标签的方式。
另:eclipse编辑web.xml的时候,总是卡死,是因为xml头版本的问题,里面的版本数字要一致。
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_9" version="3.0" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_3_0.xsd">
如上,都是3.0的。
struts2设置index.action为主页(另:web.xml编辑卡死问题解决)的更多相关文章
- struts2不同版本在核心filter在web.xml中的配置
FilterDispatcher是struts2.0.x到2.1.2版本的核心过滤器.配置如下: <filter> <filter-name>struts2</filte ...
- struts2 ,web.xml中配置为/*.action,运行报错Invalid <url-pattern> /*.action in filter mapp
首先,修改成: <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/ ...
- Tomcat设置默认启动项目及Java Web工程设置默认启动页面
Tomcat设置默认启动项目 Tomcat设置默认启动项目,顾名思义,就是让可以在浏览器的地址栏中输入ip:8080,就能访问到我们的项目.具体操作如下: 1.打开tomcat的安装根目录,找到Tom ...
- Struts2 设置global timer
设置全局的timer需要在web.xml中添加servlet, 并设置load-on-startup 为 1, 然后在servlet的init()中开启timer, 具体代码如下: 1. web.xm ...
- struts2配置文件的加载顺序以及 struts.xml package 的配置说明
查看StrutsPrepareAndExecuteFilter:(核心过滤器)两个功能 :预处理 和 执行 在预处理功能中 init 方法中会有加载配置文件的代码: dispatcher.init() ...
- web.xml 模板和Servlet版本
最近没事干,写自己小项目(项目周期无限长.开发效率无限低)的时候,遇到web.xml的dtd声明不正确,这里罗列下从Eclipse里新建项目时,自动生成的web.xml,供以后遇到类似问题的时候进行参 ...
- 绕过/*,web.xml直接访问jsp
web.xml中如果配置了/* 全匹配,那么不能用servet去响应页面返回了,因为全都被会/*拦截. <servlet> <servlet-name>validateAuth ...
- web.xml基本配置描述
先加载一段写好的web.xml: <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2. ...
- 绕过/*,web.xml直接访问jsp【转】
web.xml中如果配置了/* 全匹配,那么不能用servet去响应页面返回了,因为全都被会/*拦截. <servlet> <servlet-name>validateAuth ...
随机推荐
- bzoj 4069~4071 APIO2015
T1 从高到底按位确定答案 A=1时f[i]表示前i个数合法的划分至少需要分出几段,时间复杂度$O(n^2log(ans))$ A>1时f[i][j]表示前i个数划分为j段是否可能合法,转移显然 ...
- PAT 甲级 1009 Product of Polynomials (25)(25 分)(坑比较多,a可能很大,a也有可能是负数,回头再看看)
1009 Product of Polynomials (25)(25 分) This time, you are supposed to find A*B where A and B are two ...
- 【转载】Python ConfigParser的使用
1.基本的读取配置文件-read(filename) 直接读取ini文件内容-sections() 得到所有的section,并以列表的形式返回-options(section) 得到该section ...
- 深入理解基于selenium的二次开发
对于做web端自动化测试的人来说,可能接触selenium比QTP还要多,但是我们在做基于selenium的二次开发的时候,经常会说到二次开发是为了易于维护,很多人可能不懂得维护的价值是什么,和到底要 ...
- WPF DataGrid实现分页显示
主要代码如下 /// <summary> /// 读取指定页面的数据 /// </summary> /// <param name="pagePerCount& ...
- leetcode400
public class Solution { public int FindNthDigit(int n) { //StringBuilder sb = new StringBuilder(); / ...
- [X264] MinGW编译x264,VC中调用libx264.dll-------------<参考转>
1. 下载并按照MinGW,最好就缺省按照 http://sourceforge.net/projects/ ... ler/mingw-get-inst/ 把C:\MinGW\bin添加 ...
- UIview需要知道的一些事情:setNeedsDisplay、setNeedsLayout
UIview需要知道的一些事情:setNeedsDisplay.setNeedsLayout 1.在Mac OS中NSWindow的父类是NSResponder,而在i OS 中UIWindow 的父 ...
- context和aop
context可以看作是模切关注点,通过给join point(即被织入的业务)标记自定义属性(point cut,继承自ContextAttribute),可以得到context,然后advice具 ...
- WSAStartup function
[WSAStartup function] Parameters wVersionRequested [in] The highest version of Windows Sockets speci ...