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. Spring+Hibernate配置多数据源

    配置说明 在实际应用中,经常会用到读写分离,这里就这种情况进行Spring+Hibernate的多数据源配置.此处的配置只是让读的方法操作一个数据库,写的方法操作另外一个数据库. 注:我这里的配置JD ...

  2. [ionic开源项目教程] - 第11讲 封装BaseController实现controller继承

    关注微信订阅号:TongeBlog,可查看[ionic开源项目]全套教程. 截止到第10讲,tab1[健康]模块的功能基本已经完成了,但这一讲中,controller层又做了较大的改动,因为下一讲中t ...

  3. hdu 4614 pieces 状态DP

    题意:给你一个长度小于等于16的字符串,每次可以删除一个回文传,问你最少删除干净的字数. 状态+dp dp[i] = min(dp[i],dp[j]+dp[j^i]);(j是i的字串): 连接:htt ...

  4. 编译安装apache+php(加常见问题解决)

    [编译apache]./configure --prefix=/usr/local/lamp/httpd -with-apr=/usr/local/apr -with-apr-util=/usr/lo ...

  5. BZOJ 1078 斜堆

    感谢MATO大神的博客 http://www.cppblog.com/MatoNo1/archive/2013/03/03/192131.html 注意细节. #include<iostream ...

  6. 07day1

    怒跪了.   砍树 排序 [问题描述] 小 A 在一条水平的马路上种了 n 棵树,过了几年树都长得很高大了,每棵树都可以看作是一条长度为 a[i]的竖线段.由于有的树过于高大,挡住了其他的树,使得另一 ...

  7. (转)每天一个Linux命令(6):mv

    mv命令是move的缩写,可以用来移动文件或者将文件改名(move (rename) files),是Linux系统下常用的命令,经常用来备份文件或者目录. 1.命令格式: mv [选项] 源文件或目 ...

  8. 【英语】Bingo口语笔记(72) - play系列

  9. Android adb shell命令大全

    1. 显示系统中全部Android平台: android list targets 2. 显示系统中全部AVD(模拟器): android list avd 3. 创建AVD(模拟器): androi ...

  10. ERROR:The requested URL could not be retrieved解决方法

    ERROR 错误 The requested URL could not be retrieved 您所请求的网址(URL)无法获取 While trying to retrieve the URL: ...