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的更多相关文章

  1. [SharePoint] SharePoint 错误集 1

    1. Delete a site collection · Run command : Remove-SPSite –Identity http://ent132.sharepoint.hp.com/ ...

  2. Spring Web Flow 简介

    Spring Web Flow 简介 博客分类: 转载 SSH 最近在TSS上看到了一片介绍Spring Web Flow的文章,顺便就翻译了下来,SWF的正式版估计要到6月份才能看到了,目前的例子都 ...

  3. 用Eclipse+ADT创建可运行项目,创建lib项目,引用一个lib项目

    Managing Projects from Eclipse with ADT In this document Creating an Android Project  创建可运行项目 Settin ...

  4. Using PL/SQL APIs as Web Services

    Overview Oracle E-Business Suite Integrated SOA Gateway allows you to use PL/SQL application program ...

  5. Jenkins-client模式配置

    Jenkins配置master-slave模式 本来想着先写一篇jenkins安装的流程,但是现在jenkins做的已经非常完善了,有.war文件,直接在tomcat启动即可,所以这里就不多说了,小白 ...

  6. SharePoint 错误集

    1. Delete a site collection · Run command : Remove-SPSite –Identity http://ent132.sharepoint.hp.com/ ...

  7. USB学习笔记连载(二十一):CY7C68013A进行数据传输(一)

    官方手册中给出了bulkloop参考例程,此例程是PC从端口2发送出数据,然后从端口6接收到数据,那么根据这个思想,可以进行修改,使得PC机接收到的数据不是从EP2发送过来的,而是从外部逻辑,比如FP ...

  8. 【RabbitMQ】 RabbitMQ安装

    MQ全称为Message Queue, 消息队列(MQ)是一种应用程序对应用程序的通信方法.应用程序通过读写出入队列的消息(针对应用程序的数据)来通信,而无需专用连接来链接它们.消息传递指的是程序之间 ...

  9. CentOS7系列--5.1CentOS7中配置和管理KVM

    CentOS7配置和管理KVM 安装与配置虚拟化软件KVM ( Kernel-based Virtual Machine ) + QEMU,它要求计算机的CPU支持Intel VT or AMD-V功 ...

随机推荐

  1. volley(2) 参数code : or_barcode, pr_ismsd:false , method:GET

    1. 来自于WHCombineBatchFragment.java /** * 当编辑框里面的内容完成的时候,自动的,同时获取服务器的批量数 */private void barcodeEnterEv ...

  2. memcached增删改查

    1)add语法:add key flag expire byteskey 键flag 标志expire 过期时间,可以是秒或一个具体的时间戳bytes 要存的东西的bytes长度 PS:只能添加内存里 ...

  3. HDU 5358 First One 求和(序列求和,优化)

    题意:给定一个含n个元素的序列,求下式子的结果.S(i,j)表示为seq[i...j]之和.注:对于log20可视为1.数据量n<=105. 思路:即使能够在O(1)的时间内求得任意S,也是需要 ...

  4. LeetCode Valid Number 有效数字(有限自动机)

    题意:判断一个字符串是否是一个合法的数字,包括正负浮点数和整形. 思路:有限自动机可以做,画个图再写程序就可以解决啦,只是实现起来代码的长短而已. 下面取巧来解决,分情况讨论: (1)整数 (2)浮点 ...

  5. acdream 1412 2-3Trees (组合+DP)

    题意:2-3树的每个结点(除了叶子外)有2或3个孩子(分支),假设是一个满2-3树,那么给出叶子的数量,求这样的树有多少棵.(注:有2个孩子的结点视为相同,有3个孩子的结点视为相同,比如倒数第2层有4 ...

  6. 【英语】Bingo口语笔记(41) - 有关爱情的表达

  7. 【Python】入门 list有些不懂

    # -*- coding: utf-8 -*- # -*- coding: cp936 -*- 首行加这个 代码里就可以加注释 raw_input("Press Enter Exit&quo ...

  8. Linux用户(组)管理

    在linux中系统中,它并不认识帐号名称.它认识的是我们的帐号ID,帐号ID保存在/etc/passwd文件中.我们在登录linux主机时,在输入完帐号和密码时,linux会先查找/etc/passw ...

  9. Linux/Unix shell 自动发送AWR report(二)

    观察Oracle数据库性能,Oracle自带的awr 功能为我们提供了一个近乎完美的解决方案,通过awr特性我们可以随时从数据库提取awr报告.不过awrrpt.sql脚本执行时需要我们提供一些交互信 ...

  10. 大数据分析的众包平台—Kaggle

    众包(Jeff Howe,2006)是一种在互联网蓬勃发展的背景下产生的一种创新的生产组织形式.在这样的商业模式下,企业利用网络将工作分配出去,通过让更合适的人群参与其中来发现创意和解决技术问题.比较 ...