Struts ForwardAction Example
In Struts MVC model, you have to go thought the Action Controller to get a new view page. In some cases, you really just need to get a specified JSP page only, it’s so stupid to create an action controller class which just forward the page to you, for example
public ActionForward execute(ActionMapping mapping,ActionForm form,
HttpServletRequest request,HttpServletResponse response)
throws Exception {
return mapping.findForward("success");
}
<action path="/Welcome"
type="com.mkyong.common.action.WelcomeAction">
<forward name="success" path="/Welcome.jsp"/>
</action>
Struts comes with a special action controller class called ForwardAction (org.apache.struts.actions.ForwardAction), to do the “forward-only” task as name described, and allow you to access the specified JSP page directly.
Example
Declare a “/Welcome” web path, type attribute as ForwardAction class, and forward it to Welcome.jsp page.
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>
Welcome.jsp
This is Welcome Page
Create a index.jsp page, when user click on the link, it will forward to “/Welcome” (return Welcome.jsp)
<%@taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
ForwardAction Example
Click me to access to JSP Welcome page
http://localhost:8080/StrutsExample/ , click on the link.

It will forward to http://localhost:8080/StrutsExample/Welcome.do

Struts ForwardAction Example的更多相关文章
- Struts之ForwardAction
在Struts中,通过action跳转jsp,但是有时希望仅仅只是跳转页面,而不需要action,这时可以用ForwardAction. 定义一个仅仅是跳转的ForwardAction如下: < ...
- Struts核心技术简介
Struts核心技术简介 1.Struts内部机制 Struts是一种基于MVC经典设计模式的开发源代码的应用框架,它通过把Servlet.JSP.JavaBean.自定义标签和信息资源整合到一个 ...
- Struts 笔记 内部资料 请勿转载 谢谢合作
Struts 概述 随着MVC 模式的广泛使用,催生了MVC 框架的产生.在所有的MVC 框架中,出现最早,应用最广的就是Struts 框架. Struts 的起源 Struts 是Apache 软件 ...
- 教你如何精通Struts:Tiles框架
Tiles框架特性和内容 Tiles框架为创建Web页面提供了一种模板机制,它能将网页的布局和内容分离.它允许先创建模板,然后在运行时动态地将内容插入到模板中.Tiles 框架建立在JSP的inclu ...
- Struts – Multiple configuration files example
Many developers like to put all Struts related stuff (action, form) into a single Struts configurati ...
- 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 ...
- SSH—Struts(三)—跑步者(Action)
如已经描述Struts其基本原理和控制器ActionServlet,根据一个请求通过流ActionServlet之后就要到达Action类中做详细的处理了.ActionServlet通过ActionM ...
- struts2.1.6教程二、struts.xml配置及例程
1.配置文件的优先级 在struts2中一些配置(比如常量)可以同时在struts-default.xml(只读性),strtus-plguin.xml(只读性),struts.xml,struts. ...
- 层层递进Struts1(三)之Struts组成
这篇博客我们来说一下Struts的主要组成我们,通过前几篇博客,我们知道这个框架最重要的几个步骤:获取路径.封装表单.获取转向列表.转向逻辑处理.转向,与此对应的是:ActionServlet.Act ...
随机推荐
- java.lang.InstantiationException: DWR can't find a spring config. See the logs for solutions
在spring整合dwr时,报找不到配置文件 DWRcan't find a spring config. See the logs for solutions 解决办法: 在web.xml中添加一下 ...
- SQL计算实际工作日(天)及两个时间(工作日)间隔(小时)!
Code highlighting produced by Actipro CodeHighlighter (freeware)-->去掉法定节假日(周六,周天)和指定节假日 USE [DBNa ...
- 一个简单的ORM制作(CURD操作类)
SQL执行类 CURD操作类 其他酱油类 此篇是为上篇文章填坑的,不知道上篇砸过来的砖头够不够,不够的话请大家继续砸. CURD操作类负责将用户提供的条件转换为SQL语句,并提供给IHelper执行, ...
- myisam 与innodb的区别
myisam 与innodb的区别 frm结构 fri索引 frd数据 innodb:一个表一个文件:frm文件 所有的innodb表,都使用表空间储存, 数据和索引的保存文件不同,myisam 分开 ...
- application tips
trace(ApplicationDomain.currentDomain == ApplicationDomain.currentDomain); trace(stage.loaderInfo.ap ...
- ASIHTTPRequest详解
ASIHTTPRequest对CFNetwork API进行了封装,并且使用起来非常简单,用Objective-C编写,可以很好的应用在Mac OS X系统和iOS平台的应用程序中.ASIHTTPRe ...
- A woman without arms
任吉美出生在中国烟台海阳一个极为普通的渔民家里.她先天残疾,没有胳膊和手. 小吉美注定要比别人生活得更艰难.她不能自己穿衣,不能自己端碗吃饭,也不能像兄弟姐妹们一样帮助妈妈干家务活,她觉得自己成了家里 ...
- Android开发之旅:环境搭建及HelloWorld
引言 本系列适合0基础的人员,因为我就是从0开始的,此系列记录我步入Android开发的一些经验分享,望与君共勉!作为Android队伍中的一个新人的我,如果有什么不对的地方,还望不吝赐教. 在开始A ...
- Android基于XMPP Smack openfire 开发的聊天室
Android基于XMPP Smack openfire 开发的聊天室(一)[会议服务.聊天室列表.加入] http://blog.csdn.net/lnb333666/article/details ...
- Code Hard or Go Home
介绍Webkit的渊源 http://hypercritical.co/2013/04/12/code-hard-or-go-home