- 浏览: 19447 次
- 性别:
- 来自: 无锡
最新评论
-
丿蓝轩:
代码没给齐。。。。
struts2 的批量删除功能完整例子
文章列表
虽然大部分知道,但觉得概括得挺好,转载了,一个群上帐号出来的,不知道出处...
1、程序中,
保证在实现功能的基础上,尽量减少对数据库的访问次数;
通过搜索参数,尽量减少对表的访问行数,最小化结果集,从而减轻网络负担;
能够分开的操作尽量分开处理,提高每次的响应速度;
在数据窗口使用SQL时,尽量把使用的索引放在选择的首列;
算法的结构尽量简单;
在查询时,不要过多地使用通配符如SELECT * FROM T1语句,要用到几列就选择几列如:SELECT COL1,COL2 FROM T1;
在可能的情况下尽量限制尽量结果集行数如:SELECT TOP 300 COL1,COL ...
基于注解的方式实现的。主要代码:
@Action(value = "generateRandImg", results = { @Result(name = "result", type = "stream", params = {
"contentType", "image/jpeg", "inputName", "resultStream" }) })
public String generateRandImg() thro ...
首先在spring的applicationContext.xml里配置hibernate的配置和hibernatetemplate。
<bean id="hibernateTemplete" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory" ref="sessionFactory"&g ...
spring的装配方式有很多种,我主要学习了下autowire=byType,byName,constructor的用法。他们的配置文件和代码如下:
类文件
public class Person {
private String name;
private Home myhome;
public Person(Home myhome){
this.myhome = myhome;
}
public String getName() {
return name;
}
pu ...
spring是很强大的:把这几天学习的心得记录下来。
常用的有两种注入方式,set值注入,构造注入。
set注入的xml写法如下:
<bean id="chinese" class="Chinese">
<property name="name" value="wanger"/>
<property name="age" value="22"/>
<property name= ...
struts2 方法代码:
public String batchDelete() throws UnsupportedEncodingException {
simple = new SimpleCRUDImpl();
simple.doBatchDelete(ids);
byte[] buff = "you batchdelete some record succeed!".getBytes("UTF-8");
resultStream = new ByteArrayInputStream(buff, 0, buff.length); ...
jQuery代码:
$(function() {
//全选、反选
$('#chooseAll').click(function() {
var list = $('[name=ids]').length;
if ($('#chooseAll').attr("checked") == true) {
for ( var i = 0; i < list; i++) {
$('[name=ids]').attr("checked", "true");
}
} else if ($('# ...
直接贴代码:
public class CountTransactionDao {
public int countTransaction(){
Configuration conf = new Configuration().configure();
SessionFactory sf = conf.buildSessionFactory();
Session session = sf.openSession();
// Transaction tx = session.beginTransaction();
int count = ((Number ...
直接贴代码
action类代码:
public class UploadAction extends ActionSupport {
/**
*
*/
private static final long serialVersionUID = 1L;
private File file;
private String fileFileName;
private String fileFileType;
@SuppressWarnings("deprecation")
@Override
public String execute() throws E ...
action 类方法
public String view() {
simple = new SimpleCRUDImpl();
PageNavigateCalculator pnc = new PageNavigateCalculator();
pnc.setTotalRowsAmount(simple.doCountTransaction());
System.out.println(pnc.getTotalRowsAmount());
pnc.setCurrentPage(page);
totalpage = pnc.getTotalPages();
pre = ...
public String delete() throws UnsupportedEncodingException {
simple = new SimpleCRUDImpl();
simple.doDelete(news.getId());
byte[] buff = null;
buff = "you delete news succeed".getBytes("utf-8");
resultStream = new ByteArrayInputStream(buff, 0, buff.length);
return SUCC ...