以前都是使用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;

最新文章

  1. ASP.NET跨平台最佳实践
  2. UVa 712 S树
  3. CentOS 7 运行级别切换
  4. 注意,ruby循环体定义的变量在结束时后,变量还存在
  5. 传说中的WCF(9):流与文件传输
  6. C++ 四则运算简单设计
  7. bzoj3261: 最大异或和
  8. DLL程序的创建步骤和測试程序
  9. QML之窗口(无边框、透明及拖拽)
  10. 设计模式--装饰者设计模式(Decorator)
  11. 英文汉语切换的导航栏,纯css制作。
  12. Linux必备操作vim
  13. Github上怎么修改别人的项目并且提交给原作者!图文并茂!
  14. 知识小罐头03(idea+maven+部署war包到tomcat 上)
  15. cssselector元素定位
  16. 买了第一台mac
  17. IIS 域名 带参数 设置重定向
  18. RecyclerView错误
  19. img的src不连接本地地址实现输出一个图片(使用base64)
  20. 二,windows下安装memcached服务

热门文章

  1. 微信sdk 隐藏右上角菜单项
  2. manacher/马拉车常用用法一览
  3. sprintf、fprintf和printf这三个函数有什么区别?
  4. MySQL初始化(35-03)
  5. maven配置步骤
  6. &lt;Python基础&gt;装饰器的基本原理
  7. Python数据格式化
  8. spring:AOP面向切面编程02
  9. CF627A Xor Equation
  10. CDN与智能DNS原理和应用