struts2的action编写
例 HelloWorld.jsp
<% @ page contentType = "text/html; charset=UTF-8 " %>
<% @ taglib prefix = "s" uri = "/struts-tags " %>
<html>
<head>
<title> Hello World! </title>
</head>
<body>
<h2><s:property value ="message"/></h2>
</body>
</html>
例 classes/tutorial/HelloWorld.java
import com.opensymphony.xwork2.ActionSupport;
public class HelloWorld extends ActionSupport {
private String message ;
public String getMessage() {
return message;
}
public void tring setMessage(String message) {
this.message=message;
}
@Override
public String execute () {
message = " Hello World, Now is " + DateFormat.getInstance().format( new Date());
return success;
}
}
例 classes/struts.xml中HelloWorld Action的配置
<package name ="ActionDemo" extends ="struts-default">
<action name ="HelloWorld" class ="tutorial.HelloWorld">
<result> /HelloWorld.jsp </result>
</action>
</package>
struts2的action编写的更多相关文章
- Struts2之Action
Struts2之Action MVC模式中需要有一个控制器来负责浏览器与服务器之间的通信,实现用户与服务器的交互.在Struts2框架中实现这一功能的是Action,它是整个框架最核心的部分.Acti ...
- Struts2(二)——配置文件struts2.xml的编写
接上一篇博客,这篇博客讲述一下2——9小标题的内容,这些问题都可以在struts2配置文件中设置(当然有的也可以在Struts.properties属性文件,web.xml中进行设置),而且常规开发中 ...
- Struts2之Action的实现
对于Struts2框架来说,最重要的莫过于Action类的编写,类比于Servlet,Action类也是通过类的实例对象调用方法来处理请求的,Action类的实例对象是由Struts2的核心Filte ...
- Struts2初学 Struts2的action接收用户数据方式
一.简介 开发Web应用程序,首先应会遇到对用户输入数据的接收,传统的Web应用程序是由开发人员调用HttpServletRequest的getparameter(String name)方法从 ...
- Struts2 配置Action详解
Struts2的核心功能是action,对于开发人员来说,使用Struts2主要就是编写action,action类通常都要实现com.opensymphony.xwork2.Action接口,并实 ...
- SSH框架-Struts2基础-Action
Struts2的目录结构: 解压apps目录下的struts2-blank.war: 仿照这个最基本的项目,拷贝相关文件: 1.拷贝apps/struts2-blank/WEB-INF/classes ...
- 基于用户登陆的struts2中action的分类详解
在struts2中action的分类有:继承 ActionSupport 实现 Action,模型驱动(ModelDriven)的 Action,多方法的 Action三种方式. 1.继承 Actio ...
- Struts2中Action类的三种写法
一.普通的POJO类(没有继承没有实现)-基本不使用 POJO(Plain Ordinary Java Object)简单的Java对象,实际就是普通JavaBeans,是为了避免和EJB混淆所创 ...
- 3.Struts2中Action类的三种写法
一.普通的POJO类(没有继承没有实现)-基本不使用 public class DemoAction1 { public String execute(){ System.out.println(&q ...
随机推荐
- bzoj 1430: 小猴打架
1430: 小猴打架 Time Limit: 5 Sec Memory Limit: 162 MBSubmit: 634 Solved: 461[Submit][Status][Discuss] ...
- 拓扑排序 最大字典序+优先队列 BZOJ 4010
http://www.lydsy.com/JudgeOnline/problem.php?id=4010 4010: [HNOI2015]菜肴制作 Time Limit: 5 Sec Memory ...
- Codeforces Beta Round #34 (Div. 2) E. Collisions
E. Collisions time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...
- Eng1—English daily notes
English daily notes 2015年 4月 Phrases As a side note 作为附注,顺便说句题外话,和by the way意思相近,例句 As a side note, ...
- 【Codeforces752D】Santa Claus and a Palindrome [STL]
Santa Claus and a Palindrome Time Limit: 20 Sec Memory Limit: 512 MB Description 有k个串,串长都是n,每个串有一个a ...
- String类的一些常用操作方法
package com.liveyc.framework.util; import java.io.UnsupportedEncodingException; import java.net.URLD ...
- 【转】CentOS7 yum方式配置LAMP环境
采用Yum方式搭建: Apache+Mysql+PHP环境 原文地址: http://www.cnblogs.com/zutbaz/p/4420791.html 1.安装Apache yum inst ...
- NYOJ 756 重建二叉树 (二叉树)
题目链接 描述 题目很简单,给你一棵二叉树的后序和中序序列,求出它的前序序列(So easy!). 输入 输入有多组数据(少于100组),以文件结尾结束.每组数据仅一行,包括两个字符串,中间用空格隔开 ...
- 爬虫实战--使用Selenium模拟浏览器抓取淘宝商品美食信息
from selenium import webdriver from selenium.webdriver.common.by import By from selenium.common.exce ...
- 伪ajax操作
什么是伪Ajax操作? 说白了就是假的ajax操作,但是它和正常的ajax操作的目的是一样的,把前端的信息发送到后台 先看一下代码吧! ajax.html <form action=" ...