package com.sun;

import java.util.List;
import java.util.Map; import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration; import com.denglu.domain.User;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport; public class TestAction extends ActionSupport{
private Map request;
public Configuration config;
public SessionFactory sessionfactory;
public Session session;
public Transaction ts;
private User user;
public TestAction(){
config = new Configuration();
sessionfactory = config.configure("hibernate.cfg.xml").buildSessionFactory();
session = sessionfactory.openSession();
}
public String List(){
//User uu = new User();
List uu = (List) session.createQuery("from User").list();
System.out.println("lalalal "); for(int i =0;i<uu.size();i++){
User user = (User) uu.get(i);
System.out.println(user.getName() + user.getPwd());
}
request = (Map) ActionContext.getContext().get("request");
request.put("user", uu);
session.close();
return "sucess";
}
public String Del(){
ts = session.beginTransaction();
User u=(User) session.load(User.class,4);
session.delete(u);
ts.commit();
return "sucess";
} }
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <constant name="struts.devMode" value="true" /> <package name="default" namespace="" extends="struts-default"> <action name="index" class="com.sun.TestAction" method="List"> <result name="sucess"> /WEB-INF/index.jsp </result> </action> <action name="del" class="com.sun.TestAction" method="Del"> <result name="sucess" type="redirect"> index </result> </action> </package> <!-- Add packages here --> </struts>

通过配置action中的result 元素的返回方式为重定向,返回是调用某个Action就能够实现

一般删除一条记录之后,都会想跳转会原来的显示记录的页面,就跟你在百度留言后,直接显示出你的留言一样,这里通过Struts2进行实现

Struts2 删除后直接直接到List显示页面的更多相关文章

  1. Magento 2.2.5和2.2.6的bug 产品设置special price又删除后价格排序有误

    Magento 2.2.5和2.2.6的bug 产品设置special price又删除后价格排序有误 一.问题描述:版本2.2.5和2.2.6均有此问题,为Magento2的系统bug.为产品设置s ...

  2. Linux磁盘空间被占用问题 (分区目录占用空间比实际空间要大: 资源文件删除后, 空间没有真正释放)

    问题说明:IDC里的一台服务器的/分区使用率爆满了!已达到100%!经查看发现有个文件过大(80G),于是在跟有关同事确认后rm -f果断删除该文件.但是发现删除该文件后,/分区的磁盘空间压根没有释放 ...

  3. mui 列表项左右滑删除功能升级(仿微信左滑 点击删除后出现确认删除)

    mui 列表项左右滑删除功能升级(仿微信左滑 点击删除后出现确认删除) 2018-06-19更新显示样式

  4. 压缩Sqlite数据文件大小,解决数据删除后占用空间不变的问题

    最近有一网站使用Sqlite数据库作为数据临时性的缓存,对多片区进行划分 Sqlite数据库文件,每天大概新增近1万的数据量,起初效率有明显的提高,但历经一个多月后数据库文件从几K也上升到了近160M ...

  5. Tomcat7服务器删除后重新安装失败问题

    学习JSP时,需要修改conf下的配置文件,确发现无论如何修改权限都无法保存,所以决定卸载重装到D盘,卸载时又弹出一个对话框,具体内容没看,但是就是卸载不了,所以打算手动删除. 删除后,重装时安装失败 ...

  6. 应用删除后 Launchpad 上仍有应用图标无法删除的解决方法

    应用删除后 Launchpad 上仍有应用图标上带有问号且无法删除时,可以将 launchpad 重置. 在终端输入: defaults write com.apple.dock ResetLaunc ...

  7. Flash设置全屏后,放到网页中显示不正常

    stage.displayState = StageDisplayState.FULL_SCREEN;//全屏,注意当设置全屏后,放到网页中显示不正常

  8. IOS7 UITableView一行滑动删除后 被删除行的下一行的点击事件将被忽略解决办法

    - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSI ...

  9. MySQL误操作删除后,怎么恢复数据?

    MySQL误操作删除后,怎么恢复数据?登陆查数据库mysql> select * from abc.stad;+----+-----------+| id | name |+----+----- ...

随机推荐

  1. hiho一下103周 平衡树·Treap

    平衡树·Treap 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 小Ho:小Hi,我发现我们以前讲过的两个数据结构特别相似. 小Hi:你说的是哪两个啊? 小Ho:就是二 ...

  2. windows C 与 linux C区别?

    windows C库格式为  .dll( 动态链接库英文为DLL,是Dynamic Link Library 的缩写形式,DLL是一个包含可由多个程序同时使用的代码和数据的库,DLL不是可执行文件). ...

  3. SharePoint 2010 产品六大功能模块

    对IT专业人员来说,新的产品,意味着新的功能,IT生产力提高的契机,更加关心如何使用新产品投入更少,产出更多.在本文中我们通过对SharePoint 2010产品的功能介绍.管理中心新功能介绍.系统新 ...

  4. struts2.0 struts.xml配置文件详解

    <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN&quo ...

  5. mangos搭建

    github地址:https://github.com/mangos/MaNGOS MaNGOS 是( Massive Network Game Object Server) 的缩写.由于暴雪公司对类 ...

  6. Cut the Cake(大数相乘)

      MMM got a big big big cake, and invited all her M friends to eat the cake together. Surprisingly o ...

  7. LNMP一键安装脚本

    #!/bin/bash #LNMP(Fastcgi) #CentOS + MySQL 5.5 #-- iptables -F iptables -X iptables -Z iptables -A I ...

  8. c#反序列化

    C#序列化(转载) 2011-03-15  |  凯之风  |  转藏(2) 序列化有下列要求: A> 只序列化PUBLIC的成员变量和属性 B> 类必须有默认识构造函数 C> 如果 ...

  9. VMware连不上网解决

    在VMware里安装了ubuntu,但是某一天打开它,ubuntu忽然不能上网了,于是百度了好几个方法,最后是这样解决的: 额...现在连接的是无线,前两天出问题的时候连接的是有线,在Internet ...

  10. selenium python presence_of_element_located vs visibility_of_element_located

    背景: 用WebDriverWait时,一开始用的是presence_of_element_located,我对它的想法就是他就是用来等待元素出现.结果屡屡出问题.元素默认是隐藏的,导致等待过早的就结 ...