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 ...
随机推荐
- spring 源码如何导入到eclipse
spring 源码如何导入到eclipse spring源码解析——spring源码导入eclipse spring framework源码下载并导入eclipse
- sqlnet.ora限制客户端IP访问
实现功能: 只允许某几个IP访问数据库服务端(白名单): $ORACLE_HOME/network/admin/sqlnet.ora 添加2个主要参数 TCP.VALIDNODE_CHECKING=y ...
- suse 安装gcc
1)挂载ISO镜像 新建一个目录: mkdir /mnt/iso 将ISO文件挂载到该目录上: mount -o loop /opt/SLES-11-SP3-DVD-x86_64-GM-DVD1.is ...
- FancyButtons一个漂亮按钮的库
一个功能强大且全面的按钮控件,是目前我见过的最好使的按钮. 支持给按钮添加图标,并且可通过属性设置手指按钮的效果,不需要在写<selector>文件. 项目地址:https://git ...
- 简单神经网络TensorFlow实现
学习TensorFlow笔记 import tensorflow as tf #定义变量 #Variable 定义张量及shape w1= tf.Variable(tf.random_normal([ ...
- php 文件缓存类
//文件缓存类 class FileCache { private $cacheTime = 3600; //默认缓存时间 秒 private $cacheDir = './filecache'; / ...
- python报头解决粘包简单实现
client------------- #!/usr/bin/env python # encoding: utf-8 # Date: 2018/6/5 import socketimport st ...
- 小程序本作用域下怎么调用全局js
本地wxml文件 <view>app版本:{{version}}</view> 本地js文件 var app; Page({data:{ }, onLoad:function( ...
- KVC & KVO 入门
KVC: 简介: 全称 Key-Value Coding .KVC是一种间接访问对象属性(用字符串表征)的机制,而不是直接调用对象的accessor(setter/getter)方法或是直接访问成员对 ...
- 读取Excel里面的内容转为DataTable
using System; using System.Collections.Generic; using System.Data; using System.Data.OleDb; using Sy ...