struts1 总结吧
以前都是使用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 总结吧的更多相关文章
- struts1和struts2的区别
1. 在Action实现类方面的对比:Struts 1要求Action类继承一个抽象基类:Struts 1的一个具体问题是使用抽象类编程而不是接口.Struts 2 Action类可以实现一个Acti ...
- struts1四:常用标签
struts1支持的5种标签: HTML 标签: 用来创建能够和Struts 框架和其他相应的HTML 标签交互的HTML 输入表单 Bean 标签: 在访问JavaBeans 及其属性,以及定义一个 ...
- struts1二:基本环境搭建
首先建立一个web项目 引入需要的jar包 建立包com.bjpowernode.struts创建LoginAction package com.bjpowernode.struts; import ...
- Struts2与Struts1的区别
Struts2是基于WebWork的一个全新框架.不过有了Struts1的基础,学Struts2更方便.Struts2主要改进是取代了Struts1的Servlet和Action.Struts2的核心 ...
- Struts1.x 中的 Validate 框架
转载于http://www.blogjava.net/nokiaguy/archive/2009/02/12/254421.html 一.Validator框架的优势 Validator框 ...
- Struts1.x有两个execute方法,不要重写错哦HttpServletRequest才是对的(转)
Struts1.x 的 Action 有两个 execute 哦,小心搞错! by agate - Published: 2008-05-01 [9:42 下午] - Category: 程序编码 不 ...
- struts1拦截器
Struts2已经发布一段时间了,这个版本较struts1.x版本有了很大变化,其中一个就是增加了拦截器功能.这是个非常有用的功能,可是struts1.x却没有. 其实,struts1.x可以 ...
- struts1的一些基本用法和操作
入职两周了,项目是用struts1+ibatis框架搭建的,数据库是oracle,其他还行,关键是struts1之前没用用过,所以只好在网上狂查文档,最后大致整理了一些struts1的基本使用方法. ...
- jsp\struts1.2\struts2 中文件上传(转)
jsp\struts1.2\struts2 中文件上传 a.在jsp中简单利用Commons-fileupload组件实现 b.在struts1.2中实现c.在sturts2中实现现在把Code与大家 ...
- struts1
1.简单应用示例 导入struts1的jar包,然后配置xml,写java和jsp /struts/WebRoot/Login.jsp <%@ page language="java& ...
随机推荐
- Swig c++=>C#
1.下载swig https://sourceforge.net/projects/swig/files/ 2.配置环境变量 path 添加你的swig路径 3.创建项目解决方案和一个win32 dl ...
- svg实现渐变进度圆环
效果图 <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="ut ...
- System.Convert.cs
ylbtech-System.Convert.cs 1. 程序集 mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c56 ...
- 用pymysql实现的注册登录公告练习
import pymysql #1.连接服务器 conn=pymysql.connect( host='127.0.0.1', port=3306, user='root', password='12 ...
- PAT甲级——A1113 Integer Set Partition
Given a set of N (>) positive integers, you are supposed to partition them into two disjoint sets ...
- JS之缓冲动画
原素材 main.html <!DOCTYPE html> <html lang="en"> <head> <link href=&quo ...
- 关于jar包启动遇到的问题
一.找不到propertites文件,错误如下 原因是打成的jar不包含classpath信息,需要运行时指定,命令为 -Xbootclasspath/a: 后缀在核心class搜索路径后面.常用! ...
- No converter found for return value of type: class com.alibaba.fastjson.JSON解决办法
默认情况下,springMVC的@ResponseBody返回的是String类型,如果返回其他类型则会报错.使用fastjson的情况下,在springmvc.xml配置里加入: <mvc:a ...
- 如何将存储在MongoDB数据库中的数据导出到Excel中?
将MongoDB数据库中的数据导出到Excel中,只需以下几个步骤: (1)首先,打开MongoDB安装目录下的bin文件夹,(C:\Program Files (x86)\MongoDB\Serve ...
- [转]WPF的BitmapImage的文件无法释放及内存泄露的问题
相信用过WPF的BitmapImage的,都在用类似这样的代码来解决文件无法删除的问题! 如果看看msdn上简单的描述,可以看到这样的说明: 如果 StreamSource 和 UriSource 均 ...