以前都是使用struts2,但是新公司要使用struts1,所有只有硬着头皮上了。

一、Dynamic Method Invoc

: 自定义的 Action 必须继承 DispatchAction 而不能继承  Action

public class UserAction extends DispatchAction

:  Action 中不能有 execute(......)  方法 , 否则将始终调用该方法:

: struts-config 配置文件中应该增加如下配置:
<action 。。。。parameter="method" > </action> ======================================
<action path="/user"
type="org.springframework.web.struts.DelegatingActionProxy" name="user"
parameter="method" scope="request">
<forward name="add_success" path="list.jsp"></forward>
<forward name="list" path="list.jsp"></forward>
</action>
======================================= : 通过 path.do?metho=xxx 的形式调用Action中的方法

二、FORM 书写

public class MyProductForm extends ActionForm{

    private int id;
private String goodsName;
private String goodsNo;
private String goodsType; private int[] ids = new int[0]; /** default constructor */
public MyProductForm() {
} public MyProductForm(int id) {
this.id = id;
} public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
// TODO Auto-generated method stub
return null;
} /**
* Method reset
* @param mapping
* @param request
*/
public void reset(ActionMapping mapping, HttpServletRequest request) {
// TODO Auto-generated method stub
}
  //........get set.........
} <form-bean name="myProductForm" type="com.sunmo.test.product.MyProductForm" />

二、返回JSON数据

response.setContentType("application/json;charset=UTF-8");
response.setCharacterEncoding("UTF-8");
String result = "{'success': true, 'msg': '操作成功'}";
PrintWriter pw = null;
try {
pw = response.getWriter();
pw.write(result);
pw.flush();
} catch (IOException e) {
e.printStackTrace();
} return null;

struts1 总结吧的更多相关文章

  1. struts1和struts2的区别

    1. 在Action实现类方面的对比:Struts 1要求Action类继承一个抽象基类:Struts 1的一个具体问题是使用抽象类编程而不是接口.Struts 2 Action类可以实现一个Acti ...

  2. struts1四:常用标签

    struts1支持的5种标签: HTML 标签: 用来创建能够和Struts 框架和其他相应的HTML 标签交互的HTML 输入表单 Bean 标签: 在访问JavaBeans 及其属性,以及定义一个 ...

  3. struts1二:基本环境搭建

    首先建立一个web项目 引入需要的jar包 建立包com.bjpowernode.struts创建LoginAction package com.bjpowernode.struts; import ...

  4. Struts2与Struts1的区别

    Struts2是基于WebWork的一个全新框架.不过有了Struts1的基础,学Struts2更方便.Struts2主要改进是取代了Struts1的Servlet和Action.Struts2的核心 ...

  5. Struts1.x 中的 Validate 框架

    转载于http://www.blogjava.net/nokiaguy/archive/2009/02/12/254421.html 一.Validator框架的优势       Validator框 ...

  6. Struts1.x有两个execute方法,不要重写错哦HttpServletRequest才是对的(转)

    Struts1.x 的 Action 有两个 execute 哦,小心搞错! by agate - Published: 2008-05-01 [9:42 下午] - Category: 程序编码 不 ...

  7. struts1拦截器

    Struts2已经发布一段时间了,这个版本较struts1.x版本有了很大变化,其中一个就是增加了拦截器功能.这是个非常有用的功能,可是struts1.x却没有.     其实,struts1.x可以 ...

  8. struts1的一些基本用法和操作

    入职两周了,项目是用struts1+ibatis框架搭建的,数据库是oracle,其他还行,关键是struts1之前没用用过,所以只好在网上狂查文档,最后大致整理了一些struts1的基本使用方法. ...

  9. jsp\struts1.2\struts2 中文件上传(转)

    jsp\struts1.2\struts2 中文件上传 a.在jsp中简单利用Commons-fileupload组件实现 b.在struts1.2中实现c.在sturts2中实现现在把Code与大家 ...

  10. struts1

    1.简单应用示例 导入struts1的jar包,然后配置xml,写java和jsp /struts/WebRoot/Login.jsp <%@ page language="java& ...

随机推荐

  1. 「题解」:$Game$

    问题 B: $Game$ 时间限制: 1 Sec  内存限制: 256 MB 题面 题面谢绝公开. 题解 对于最初加入的每一个元素开桶记录出现次数. 然后记录一个前p个元素最大值. 先由先手玩家取走一 ...

  2. 0927CSP-S模拟测试赛后总结

    84pts rank28 经历了一个阶段的持续低迷,终于回到自己之前的位置了啊. 尽管依旧不是太靠上,但是还是证明了我的努力. 宿舍三人的风水轮流转之谈终究只是戏言和巧合.嘟嘟和Lockey都进第一机 ...

  3. Duilib中各个类的简单介绍

    DirectUI意为直接在父窗口上绘图(Paint on parent dc directly).即子窗口不以窗口句柄的形式创建(windowless),只是逻辑上的窗口,绘制在父窗口之上.微软的“D ...

  4. 使用SharpZipLib实现zip压缩

      使用国外开源加压解压库ICSharpCode.SharpZipLib实现加压,该库的官方网站为http://www.icsharpcode.net/OpenSource/SharpZipLib/D ...

  5. CSS 继承和优先级

    CSS继承性 CSS属性继承:外层元素的样式,会被内层元素进行继承. 多个外层元素的样式,最终都会“叠加”到内层元素上. 什么样的CSS属性能被继承呢? CSS文本属性都会被继承的: color. f ...

  6. day22_6-re模块

    # 参考资料:# python模块(转自Yuan先生) - 狂奔__蜗牛 - 博客园# https://www.cnblogs.com/guojintao/articles/9070485.html ...

  7. python环境变量配置 - CSDN博客

    一.下载: 1.官网下载python3.0系列(https://www.python.org/) 2.下载后图标为: 二.安装: Window下: 1.安装路径: 默认安装路径:C:\python35 ...

  8. Web中常见的绕过和技巧

    SQL注入 十六进制绕过引号 slect table_name from information_schema.table where table_schema="sqli"; s ...

  9. PAT甲级——A1132 Cut Integer

    Cutting an integer means to cut a K digits lone integer Z into two integers of (K/2) digits long int ...

  10. WPF DataGridTextColum 显示时间格式化

    <DataGrid Name="DGVisit" Grid.Row="2" AutoGenerateColumns="False" C ...