本来是弄拦截器的问题,结果弄主页的时候,还是发现了问题。

公司网站的项目里面,是用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编辑卡死问题解决)的更多相关文章

  1. struts2不同版本在核心filter在web.xml中的配置

    FilterDispatcher是struts2.0.x到2.1.2版本的核心过滤器.配置如下: <filter> <filter-name>struts2</filte ...

  2. struts2 ,web.xml中配置为/*.action,运行报错Invalid <url-pattern> /*.action in filter mapp

    首先,修改成: <filter-mapping>  <filter-name>struts2</filter-name>  <url-pattern>/ ...

  3. Tomcat设置默认启动项目及Java Web工程设置默认启动页面

    Tomcat设置默认启动项目 Tomcat设置默认启动项目,顾名思义,就是让可以在浏览器的地址栏中输入ip:8080,就能访问到我们的项目.具体操作如下: 1.打开tomcat的安装根目录,找到Tom ...

  4. Struts2 设置global timer

    设置全局的timer需要在web.xml中添加servlet, 并设置load-on-startup 为 1, 然后在servlet的init()中开启timer, 具体代码如下: 1. web.xm ...

  5. struts2配置文件的加载顺序以及 struts.xml package 的配置说明

    查看StrutsPrepareAndExecuteFilter:(核心过滤器)两个功能 :预处理 和 执行 在预处理功能中 init 方法中会有加载配置文件的代码: dispatcher.init() ...

  6. web.xml 模板和Servlet版本

    最近没事干,写自己小项目(项目周期无限长.开发效率无限低)的时候,遇到web.xml的dtd声明不正确,这里罗列下从Eclipse里新建项目时,自动生成的web.xml,供以后遇到类似问题的时候进行参 ...

  7. 绕过/*,web.xml直接访问jsp

    web.xml中如果配置了/* 全匹配,那么不能用servet去响应页面返回了,因为全都被会/*拦截. <servlet> <servlet-name>validateAuth ...

  8. web.xml基本配置描述

    先加载一段写好的web.xml: <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2. ...

  9. 绕过/*,web.xml直接访问jsp【转】

    web.xml中如果配置了/* 全匹配,那么不能用servet去响应页面返回了,因为全都被会/*拦截. <servlet> <servlet-name>validateAuth ...

随机推荐

  1. windows mysql默认配置文件

    查询配置目录 select @@basedir; 查询数据目录 select @@datadir; 查询数据库编码 show variables like 'char% my.ini [mysql] ...

  2. 学习blus老师js(6)--js运动基础

    运动基础 一.匀速运动 运动框架 在开始运动时,关闭已有定时器 把运动和停止隔开(if/else) <!DOCTYPE HTML> <html> <head> &l ...

  3. Train-Alypay-Cloud:蚂蚁大数据平台培训开课通知(第三次)

    ylbtech-Train-Alypay-Cloud:蚂蚁大数据平台培训开课通知(第三次) 1.返回顶部 1. 您好! 很高兴通知您,您已经成功报名将于蚂蚁金服计划在2018年2月28日- 2018年 ...

  4. Oracle 性能调优之:使用 V$SQL_PLAN 视图查询内存中的执行计划

    V$SQL_PLAN视图提供了一种方法,可用于检查仍位于库高速缓存的游标的执行计划.此视图中的信息与 PLAN_TABLE 视图中的信息非常类似.但是,EXPLAIN PLAN 显示的是执行相应语句时 ...

  5. 常用工具&网址

    工具 I tell you http://www.win7999.com/news/197912345.html VisualSVN Server(免费) http://www.visualsvn.c ...

  6. echart改变legend样式及分页

    legend: { type: 'scroll', orient: 'horizontal', bottom:0, left:'center', itemGap: 0, itemWidth: 10, ...

  7. 3.Ehcache中储存缓存的方式

    转自:https://www.cnblogs.com/crazylqy/p/4238148.html 目录 1     堆内存(MemoryStore) 1.1     指定可用内存 1.2      ...

  8. 42.国际化-配置package的资源文件

    转自:https://wenku.baidu.com/view/84fa86ae360cba1aa911da02.html 同样在建立com.asm包下建立两个资源文件(package级别的资源文件名 ...

  9. 实战zabbix3.0.2 使用percona mysql插件监控mysql5.7

    1.系统环境 [root@shard0 templates]# cat /etc/redhat-release Red Hat Enterprise Linux Server release 7.2 ...

  10. Spark报错:Failed to locate the winutils binary in the hadoop binary path

    之前在mac上调试hadoop程序(mac之前配置过hadoop环境)一直都是正常的.因为工作需要,需要在windows上先调试该程序,然后再转到linux下.程序运行的过程中,报 Failed to ...