//----------------事务(修改、删除、保存)
Session s=getSession();
Transaction t=s.beginTransaction();
getSession().delete(persistentInstance);
t.commit();
//查询语句
public List<Cls> i = new ArrayList<Cls>();
public String execute(){
ClsDAO clsDAO = new ClsDAO();
i=clsDAO.findAll();
return "1"; }
//删除语句
StuDAO In=new StuDAO();
i=In.findstuid(stu_id);
In.delete(i.get(0));
//添加语句
public String stu_name;
public Integer stu_age;
public Integer cls_id;
public String execute(){
ClsDAO clsDAO = new ClsDAO();
Cls cls = clsDAO.findById(cls_id);
StuDAO stuDAO = new StuDAO();
Stu stu = new Stu(cls,stu_name,stu_age);
stuDAO.save(stu);
return "1";
}
//修改语句
public String stu_name;
public Integer stu_age;
public Integer cls_id;
public Integer stu_id;
public String execute(){
ClsDAO clsDAO=new ClsDAO();
Cls cls=clsDAO.findById(cls_id);
Stu stu=new Stu(cls,stu_name,stu_age,stu_id);//自己写个参数包含主键ID的构造函数
StuDAO studentsDAO=new StuDAO();
studentsDAO.merge(stu);
return "1";
}
//DAO里面学生表按照班级ID查询
public List findClsid(Integer cls_id) {
String queryString = "from Stu where cls_id = '"+cls_id+"'";
Query queryObject = getSession().createQuery(queryString);
return queryObject.list();
}
//JS 方式 伪网页直接访问action,用于无触发情况下,需要调用后台访问数据库取得实时数据的做法
<script type="text/javascript">
window.location.href="all.action";
</script> //S标签,遍历List数组,生成表格等数据表
<%@ taglib prefix="s" uri="/struts-tags"%>
<s:iterator value="i">
<s:property value="stuId"/>
</s:iterator>

  

//struts2
<constant name="struts.i18n.encoding" value="utf-8" />
<package name="denglu" extends=" struts-default">
<action name="all" class="com.all">
<result name="1">/all.jsp</result>
</action>
       <action name="up_save" class="com.up_save">
<result name="1" type="redirectAction">all</result>
</action>
</package>

  

a标签返回上一步
<a href="javascript:history.go(-1)">返回</a>

  JS表单不能为空检测

<script type="text/javascript">
function myCheck()
{
for(var i=0;i<document.form1.elements.length-1;i++)
{
if(document.form1.elements[i].value=="")
{
document.getElementById("showResult").innerHTML="请输入学生完整信息!";
document.form1.elements[i].focus();
return false;
}
}
return true;
}
</script> <form name="form1" action="add.action" method="post" onSubmit="return myCheck()"></form>
<span id="showResult" style="color: red;"></span>

  

  分页 在任何系统中都是非常头疼的事情,有的数据库在语法上支持分页,而有的数据库则需要使用可滚动游标来实现,并且在不支持可滚动游标的系统上只能使用单向游标逐步接近要取得的数据。
     Hibernate提供了一个支持跨系统的分页机制,这样无论底层是什么样的数据库都能用统一的接口进行分页操作。比如下面的代码就是从第500条开始取出100条记录:

Query q = session.createQuery("from FooBar as f");
q.setFirstResult(500);
q.setMaxResults(100);
List l = q.list();
  

  分页计算总页数

int intPageSize; //一页显示的记录数
int intRowCount; //记录总数
int intPageCount; //总页数
计算总页数公式:intPageCount = (intRowCount+intPageSize-1) / intPageSize

  action之间传值

<action name ="app09002Action" class ="app09002Action" >
<result name="success" type="redirect-action">
<param name="actionName">app10001Action</param>action地址
<param name="userId">${userId}</param>值
    <param name="userId">${userId}</param>值
</result> </action>

  css样式,文字下面的一根分隔线,很好看,支持IE

#wrapper h1:after{      
content: ' ';
display: block;
width: 100%;
height: 2px;
margin-top: 10px;
background: -moz-linear-gradient(left, rgba(147,184,189,0) 0%, rgba(147,184,189,0.8) 20%, rgba(147,184,189,1) 53%, rgba(147,184,189,0.8) 79%, rgba(147,184,189,0) 100%);
background: -webkit-gradient(linear, left top, right top, color-stop(0%,rgba(147,184,189,0)), color-stop(20%,rgba(147,184,189,0.8)), color-stop(53%,rgba(147,184,189,1)), color-stop(79%,rgba(147,184,189,0.8)), color-stop(100%,rgba(147,184,189,0)));
background: -webkit-linear-gradient(left, rgba(147,184,189,0) 0%,rgba(147,184,189,0.8) 20%,rgba(147,184,189,1) 53%,rgba(147,184,189,0.8) 79%,rgba(147,184,189,0) 100%);
background: -o-linear-gradient(left, rgba(147,184,189,0) 0%,rgba(147,184,189,0.8) 20%,rgba(147,184,189,1) 53%,rgba(147,184,189,0.8) 79%,rgba(147,184,189,0) 100%);
background: -ms-linear-gradient(left, rgba(147,184,189,0) 0%,rgba(147,184,189,0.8) 20%,rgba(147,184,189,1) 53%,rgba(147,184,189,0.8) 79%,rgba(147,184,189,0) 100%);
background: linear-gradient(left, rgba(147,184,189,0) 0%,rgba(147,184,189,0.8) 20%,rgba(147,184,189,1) 53%,rgba(147,184,189,0.8) 79%,rgba(147,184,189,0) 100%);
}

  

最新文章

  1. 结构struct
  2. 请求WebApi的几种方式
  3. Windows Server 2008下asp+access无法登陆问题总结
  4. Atitit python3.0 3.3 3.5 3.6 新特性&#160;Python2.7新特性1Python 3_x 新特性1python3.4新特性1python3.5新特性1值得关注的新特性1Pyth
  5. asp.net MD5 加密
  6. ROW_NUMBER()函数的使用
  7. CSS3小分队——进击的border-radius
  8. [mock]8月8日
  9. Fibonacci 数列递归 重复计算
  10. -fembed-bitcode is not supported on versions of iOS prior to 6.0
  11. BZOJ 2157: 旅游( 树链剖分 )
  12. android 给layout布局添加点击事件
  13. [原创]在HP DL380 G7服务器上部署基于Ubuntu Server 16.04 和 VirtualBox的云平台
  14. vue computed计算属性和watch监听属性解疑答惑
  15. 【杂】指针,*,&amp;
  16. 国内阿里maven仓库镜像maven配置文件maven仓库速度快
  17. Angular/Vue调用百度地图+标注点不显示图标+多标注点计算地图中心位置
  18. nginx基于目录的映射:
  19. SQL update语句 更新和查询同一张表 冲突
  20. 超级账本环境搭建fabric

热门文章

  1. [C#源码]VS各版本转换器(支持VS2012,VS2013)
  2. 修改 suse 上的postfix 的日志路径
  3. android119 侧滑菜单
  4. RHEL 7特性说明(七):编译程序及工具
  5. interactive_timeout
  6. 学习笔记之Java程序设计实用教程
  7. .net core 1.1.0 MVC 控制器接收Json字串 (JObject对象) (二)
  8. java_可变参数构造器 Bulder模式
  9. C# 之 OpenFileDialog的使用
  10. html5 list属性、autocomplete属性、pattern属性