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 ...
随机推荐
- UVa 1593 (水题 STL) Alignment of Code
话说STL的I/O流用的还真不多,就着这道题熟练一下. 用了两个新函数: cout << std::setw(width[j]); 这个是设置输出宽度的,但是默认是在右侧补充空格 所 ...
- Volley : "参数param:{ inoutNo:inoutNo ,whcode:’’}
private void fuzzySearch() { mRequestQueue = Volley.newRequestQueue(getActivity()); String str = Sha ...
- 20160201.CCPP体系详解(0011天)
内容概要:C语言基本数据类型及运算题库(含答案) 第二章 基本数据类型及运算 一.选择题 1. 若以下选项中的变量已正确定义,则正确的赋值语句是[C]. A) x1=26.8%3; B) 1+2=x2 ...
- MYSQL建立索引需要注意几点
1.建立索引的时机:若表中的某字段出现在select.过滤.排序条件中,为该字段建立索引是值得的.2.对于like '%xxx'的模糊查询,普通的索引是无法满足的,需要建立全文索引.3.对于有多个条件 ...
- AJax学习一
1.Ajax的准备工作,就是要先准备好服务器环境. 这边可以有好几种方式,例如服务器工具: http://www.php100.com/html/plugin/ser/2013/0905/91.htm ...
- 配置java环境时,java的path地址放在其他地址的前面还是后面?
PATH环境变量里是按顺序查找的,如果电脑里只有一个jdk,放哪都一样,有多个放前面的会优先. 一般是放在最前面吧,以免其他在path中的程序需要用到Java环境而由于在JAVA_PATH之前 ...
- jQuery基础知识--Form基础
form中的单行文本获取和失去焦点 <!DOCTYPE html> <html> <head lang="en"> <meta chars ...
- selenium python (六)定位一组对象
checkbox源码: <html><head><meta http-equiv="content-type" content="text/ ...
- 【转】linux之e2label命令
转自:http://www.th7.cn/system/lin/201311/46743.shtml 前言 e2label命令,用于获取或设置ext2.ext3文件系统对应的分区的卷标. 卷标:简单来 ...
- dword word byte 相互转换 .xml
pre{ line-height:1; color:#800080; background-color:#d2c39b; font-size:16px;}.sysFunc{color:#627cf6; ...