以前都是使用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. bzoj1433: [ZJOI2009]假期的宿舍 [二分图][二分图最大匹配]

    Description Input Output Sample Input 1 3 1 1 0 0 1 0 0 1 1 1 0 0 1 0 0 Sample Output ˆ ˆ HINT 对于30% ...

  2. java——万年历

    package oop; import java.util.Scanner; public class 万年历 { public static void main(String[] args) { / ...

  3. [HEOI 2018]一双木棋

    题意:求对抗分数差值最大. 思路:状压dp,维护一条轮廓线,最大化分差.可以发现上一行的棋子个数永远比这一行多. #include<bits/stdc++.h> using namespa ...

  4. day23_2_logging

    #!/usr/bin/env python# -*- coding:utf-8 -*-# ------------------------------------------------------- ...

  5. 9个搜索引擎优化(SEO)最佳实践

    作为网页设计师,搜索引擎优化重要吗?我们知道,网站设计是把屏幕上平淡无奇变成令人愉快的美感,更直观地辨认信息.这也是人与人之间在沟通想法,这样的方式一直在演变. 1. 网站结构 对于搜索引擎优化,网站 ...

  6. 《Practices of an Agile Developer:Woring in the Real World》读书笔记 PB16110698(~3.22)第三周

    <Practices of an Agile Developer:Woring in the Real World>读书笔记  本周我阅读了<高效程序员的45个习惯:敏捷开发修炼之道 ...

  7. 新安装一个eclipse,导入一个web项目,右键点击项目选择Properties,找不到project facets和Server选项。

    解决方式: 1.点击:eclipse导航栏中点击Help->Install New Software 2.点击Add添加 3在弹出框中填写以下信息 name:keep(名字随便取) locati ...

  8. css3 ---1 基本的选择器

    基本的选择器 <style type="text/css"> /*通配符选择器*/ * { margin: ; padding: ; border: none; } / ...

  9. 图论最短路径算法——Dijkstra

    说实在的,这算法很简单,很简单,很简单--因为它是贪心的,而且码量也小,常数比起SPFA也小. 主要思想 先初始化,dis[起点]=0,其它皆为无限大. 还要有一个bz数组,bz[i]表示i是否确定为 ...

  10. SaaS加速器,到底加速了谁? 剖析阿里云的SaaS战略:企业和ISV不可错过的好文

    过去二十年,中国诞生了大批To C的高市值互联网巨头,2C的领域高速发展,而2B领域一直不温不火.近两年来,在C端流量饱和,B端数字化转型来临的背景下,中国越来越多的科技公司已经慢慢将触角延伸到了B端 ...