Configure a welcome page in Struts
Every website need a welcome or default page as an entry point. Here’s 3 ways to configure a welcome page in Struts.
1. index.jsp
The simplest way is create a “index.jsp” page and put it same level with the WEB-INF folder, project root folder.
Access the project root
http://localhost:8080/StrutsExample/
It will default to index.jsp internally.
http://localhost:8080/StrutsExample/index.jsp
2. web.xml welcome file
Declare a welcome-file in web.xml file.
<welcome-file-list>
<welcome-file>
/pages/Welcome.jsp
</welcome-file>
</welcome-file-list>
Access the project root
http://localhost:8080/StrutsExample/
It will redirect to welcome.jsp file internally.
http://localhost:8080/StrutsExample/pages/Welcome.jsp
web.xml
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Maven Struts Examples</display-name>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>
org.apache.struts.action.ActionServlet
</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>
/WEB-INF/struts-config.xml
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>
/pages/Welcome.jsp
</welcome-file>
</welcome-file-list>
</web-app>
3. JSP Forward
Create a “index.jsp” file as stated in method 1, and define a JSP forward tag to redirect it to another Struts action.
index.jsp
Declare a /Welcome web path, with a ForwardAction type to forward it to another JSP file.
struts-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_3.dtd">
<struts-config>
<action-mappings>
<action
path="/Welcome"
type="org.apache.struts.actions.ForwardAction"
parameter="/pages/Welcome.jsp"/>
</action-mappings>
</struts-config>
Configure a welcome page in Struts的更多相关文章
- [SharePoint] SharePoint 错误集 1
1. Delete a site collection · Run command : Remove-SPSite –Identity http://ent132.sharepoint.hp.com/ ...
- Spring Web Flow 简介
Spring Web Flow 简介 博客分类: 转载 SSH 最近在TSS上看到了一片介绍Spring Web Flow的文章,顺便就翻译了下来,SWF的正式版估计要到6月份才能看到了,目前的例子都 ...
- 用Eclipse+ADT创建可运行项目,创建lib项目,引用一个lib项目
Managing Projects from Eclipse with ADT In this document Creating an Android Project 创建可运行项目 Settin ...
- Using PL/SQL APIs as Web Services
Overview Oracle E-Business Suite Integrated SOA Gateway allows you to use PL/SQL application program ...
- Jenkins-client模式配置
Jenkins配置master-slave模式 本来想着先写一篇jenkins安装的流程,但是现在jenkins做的已经非常完善了,有.war文件,直接在tomcat启动即可,所以这里就不多说了,小白 ...
- SharePoint 错误集
1. Delete a site collection · Run command : Remove-SPSite –Identity http://ent132.sharepoint.hp.com/ ...
- USB学习笔记连载(二十一):CY7C68013A进行数据传输(一)
官方手册中给出了bulkloop参考例程,此例程是PC从端口2发送出数据,然后从端口6接收到数据,那么根据这个思想,可以进行修改,使得PC机接收到的数据不是从EP2发送过来的,而是从外部逻辑,比如FP ...
- 【RabbitMQ】 RabbitMQ安装
MQ全称为Message Queue, 消息队列(MQ)是一种应用程序对应用程序的通信方法.应用程序通过读写出入队列的消息(针对应用程序的数据)来通信,而无需专用连接来链接它们.消息传递指的是程序之间 ...
- CentOS7系列--5.1CentOS7中配置和管理KVM
CentOS7配置和管理KVM 安装与配置虚拟化软件KVM ( Kernel-based Virtual Machine ) + QEMU,它要求计算机的CPU支持Intel VT or AMD-V功 ...
随机推荐
- [转载]流式大数据处理的三种框架:Storm,Spark和Samza
许多分布式计算系统都可以实时或接近实时地处理大数据流.本文将对三种Apache框架分别进行简单介绍,然后尝试快速.高度概述其异同. Apache Storm 在Storm中,先要设计一个用于实时计算的 ...
- 如何向hadoop集群定时提交一个jar作业?
除了使用Hive,Pig来执行一个MapReduce任务,不需要专门的把项目打成jar包,提交执行,或者定时执行,因为Hive,Pig这些开源框架已经,帮我们自动打包上传了. 而有些时候,我们自己手写 ...
- Linux 查找文件方法
1) find -name httpd.conf 2) find /etc -name "*repo" 详情查找命令-> http://www.yesky.com/210/1 ...
- LeetCode Count Primes 求素数个数(埃拉托色尼筛选法)
题意:给一个数n,返回小于n的素数个数. 思路:设数字 k =from 2 to sqrt(n),那么对于每个k,从k2开始,在[2,n)范围内只要是k的倍数的都删掉(也就是说[k,k2)是不用理的, ...
- PDO防注入原理分析以及使用PDO的注意事项 (转)
我们都知道,只要合理正确使用PDO,可以基本上防止SQL注入的产生,本文主要回答以下两个问题: 为什么要使用PDO而不是mysql_connect? 为何PDO能防注入? 使用PDO防注入的时候应该特 ...
- Python内置数据类型之Tuple篇
Tuple 是不可变的 list.一旦创建了一个 tuple,就不可以改变它.这个有点像C++中的const修饰的变量.下面这段话摘自Dive Into Python: Tuple 比 list 操作 ...
- vc判断文件是否存在
#include <io.h> #include <stdio.h> #include <stdlib.h> void main( void ) { /* Chec ...
- Mysql避免全表扫描sql查询优化 .
对查询进行优化,应尽量避免全表扫描,首先应考虑在 where 及 order by 涉及的列上建立索引: .尝试下面的技巧以避免优化器错选了表扫描: · 使用ANALYZE TABLE tbl_n ...
- js细节
1.小心函数中的“s“ getElementsByTagName:得到的是数组 getElementById:得到的是对象 2.js 中设置哪一项被选中 subject.selectedIndex = ...
- T-SQL:SQL Server-数据库查询语句基本查询
ylbtech-SQL Server-Basic:SQL Server-数据库查询语句基本查询 SQL Server 数据库查询语句基本查询. 1,数据库查询语句基本查询 数据库 SQL Serv ...