`

Struts2使用ActionSupport类传递提示信息到前台页面并获取显示

阅读更多
 /**
  * 删除用户信息
  * 
  * @return
  * @throws Exception
  */
 public String delete() throws Exception {
  
List<String> userIds = new ArrayList<String>();
  for (String id : choose) {
   userIds.add(new Integer(id));
  }
  UserObject userInfo = new UserObject();
  userInfo.setUserIds(userIds);
  tUser.setModifyUser(super.getCurrentUser().getUserId());
  userInfo.setUser(tUser);
  try {
   ServiceProvider.getService(UserService.class).deleteUser(userInfo);
  } catch (BizServiceException e) {
   addActionError(e.getErrorMessage());
  }
   addActionMessage("删除用户成功!");
   return SUCCESS;
  }

 

前台页面message.jsp:

<s:if test="hasActionErrors()">
 <div class="error">
  <s:actionerror />
 </div>
</s:if>

<s:if test="hasActionMessages()">
 <div class="message" id="message">
  <s:actionmessage />
 </div>
 <script type="text/javascript">
  highlight("message");
  window.setTimeout(function(){document.getElementById("message").style.display="none";}, 2000);
 </script>
</s:if>

 

参考资料:

http://blog.csdn.net/titilover/article/details/6792854

http://zgphacker2010.iteye.com/blog/1020527

 

分享到:
评论

相关推荐

    Struts2继承ActionSupport例子

    Struts2继承ActionSupport例子 这个是我们在上课的时候做的一个小例子,可能其中还掺杂着其他东西,跟我博客是相关联的,如果只看代码看不懂,建议大家去看一下博客。

    struts 2 基础2__继承ActionSupport完成输入校验

    struts 2 基础 __继承ActionSupport完成输入校验

    使用Spring , ActionSupport ,struts1整合实例

    使用Spring , ActionSupport ,struts1整合实例,一个简单的实例代码

    默然说话struts2入门2-标签及ActionSupport.rar-part1

    入门级,无声视频,这一集比上一集感觉拍得好多了,找到一些窍门。 对Struts2的标签导入,错误信息显示,ActionSupport类的addFieldError()方法,validate()方法,execute()方法的使用进行了介绍。

    使用Spring 的ActionSupport 类整合 Struts,Hibernate实例

    全面教你如何整合spring,Struts,Hibernate

    struts1.0和struts2

    struts1和struts2的区别其实并不是太大,两者的区别: Action 类: ◆Struts1要求Action类继承一个抽象基类。Struts1的一个普遍问题是使用抽象类编程而不是接口。 ◆Struts 2 Action类可以实现一个Action接口,也...

    默然说话struts2入门2-标签及ActionSupport.rar-part2

    入门级,无声视频,这一集比上一集感觉拍得好多了,找到一些窍门。 对Struts2的标签导入,错误信息显示,ActionSupport类的addFieldError()方法,validate()方法,execute()方法的使用进行了介绍。

    struts1和struts2的区别

    从开发者角度看,就是说需要显示给用户的数据可以直接从Action中获取,而不像Struts1.x那样,必须把相应的Bean存到Page、Request或者Session中才能获取。Struts1.x 必须继承org.apache.struts.action.Action或者其...

    Struts1与Struts2本质区别

    Struts 1的一个具体问题是使用抽象类编程而不是接口。Struts 2 Action类可以实现一个Action接口,也可以实现其他接口,使可选和定制的服务成为可能。Struts 2提供一个ActionSupport基类去实现常用的接口。即使Action...

    Struts2 in action中文版

    8.1.1 页面上:如何使用自定义结果组件构建Struts 2 Ajax应用程序 171 8.1.2 实现JSON结果类型 173 8.2 常用的结果类型 180 8.2.1 RequestDispatcher,也叫做dispatcher 180 8.2.2 ServletRedirectResult,也叫做...

    ActionSupport接口类

    action类中为何要继承ActionSupport这个接口类。

    【张冰Struts2学习笔记】0201_Action接口与ActionSupport类

    NULL 博文链接:https://coderdream.iteye.com/blog/812871

    struts2讲义_吴峻申

    7.2.2 Struts2局部异常提示定义属性文件使用介绍 146 7.2.3 Struts2全局异常提示定义属性文件使用介绍 147 第8章 Struts2输入校验 149 8.1 validate输入校验方式再谈 149 8.1.1 复习validate方法进行输入校验 149 ...

    Struts2的特点

    struts2.0的特点 1、form是一个pojo 2、action是一个pojo,所以struts2.0与框架的藕合度非常低。 实现Action时有时会继承于ActionSupport, 覆盖execute方法,从而创建一个Action。 因为ActionSupport提供了...

    深入浅出Struts2(附源码)

    本书是广受赞誉的Struts 2优秀教程,它全面而深入地阐述了Struts 2的各个特性,并指导开发人员如何根据遇到的问题对症下药,选择使用最合适的特性。作者处处从实战出发,在丰富的示例中直观地探讨了许多实用的技术,...

    自定义Action继承ActionSupport实现简单登录

    自定义Action继承ActionSupport实现简单登录,刚开始学习struts2记录一下。

    搭建好的一个struts2环境

    为了方便初学者使用Struts2,我配置了一个Struts2空项目,可以直接使用Struts2,IDE使用的是MyEclipse6.5 使用方法: 1.在包com.test.web.action添加类,比如Test1Action.java,该类需要继承ActionSupport 2.在Web...

Global site tag (gtag.js) - Google Analytics