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功 ...
随机推荐
- Incorrect key file for table '/tmp/#sql_882_0.MYI'; try to repair it
修表方法如下: 一法:. check table 和 repair table 方法1,进入Mysql 的Dos控制台,输入密码进入 2,use database;(你的数据库名) 3, check ...
- 内存分配(c/c++)
C++中内存分配 内存分成5个区,他们分别是堆.栈.自由存储区.全局/静态存储区和常量存储区. 1,栈,就是那些由编译器在需要的时候分配,在不需要的时候自动清除的变量的存储区.里面的 ...
- 随便谈谈alphago与人机大战
3月16日历时8天的人机大战终于落下帷幕,alphago以4:1的比分击败了当年如日中天的李世石.这个结果让我这个围棋爱好者+计算机爱好者百感交集…… ——一个时代落幕了,一个新的时代开启了. 这次人 ...
- [转] POJ字符串分类
POJ 1002 - 487-3279(基础)http://acm.pku.edu.cn/JudgeOnline/problem?id=1002题意:略解法:二叉查找数,map,快排... POJ 1 ...
- Android中的Drawable资源
在Android应用中,常常会用到Drawable资源,比如图片资源等,在Android开发中我们是用Drawable类来Drawable类型资源的. Drawable资源一般存储在应用程序目录的\r ...
- 优雅地使用CodeIgniter 3之Session类库(1)(转)
相信无数人在使用CI2的Session类库时,遇到各种的坑,各种抱怨,各种不解.在CI中国论坛能搜到大量关于Session类库的提问,说明要想用 好session类库还是得下一番功夫.本文将先从CI2 ...
- MySQL多表连接
主要分3种:内连接,外连接,交叉连接 其 他:联合连接,自然连接 1.内联接 典型的联接运算,使用像 = 或 <> 之类的比较运算).包括相等联接和自然联接. 内联接使用比 ...
- 今天开始自学Andrew Ng的机器学习,希望可以坚持下来
今天开始正式接触机器学习,20集的课程争取在开学前看完.每看完一集会在博客记录笔记,加油! 版权声明:本文为博主原创文章,未经博主允许不得转载.
- linux各种查看端口号
1. 查看端口占用情况的命令:lsof -i [root@www ~]# lsof -i COMMAND PID USER FD TYPE DEVICE SIZE NODE N ...
- Windows下配置cygwin和ndk编译环境
cygwin安装 正确的安装步骤其实很简单:1. 下载setup-86_64.exe 2. 直接从网上下载安装,选择包时,顶部选择“default”不变 3. 搜索make,勾选make,cmake, ...