前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Struts Spring Hibern

Struts Spring Hibern

作者头像
py3study
发布2020-01-07 10:42:44
3770
发布2020-01-07 10:42:44
举报
文章被收录于专栏:python3

三、QueryToDayInfoAction

<!--[if !supportEmptyParas]--> <!--[endif]-->

package com.jh.xh.action;

<!--[if !supportEmptyParas]--> <!--[endif]-->

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

<!--[if !supportEmptyParas]--> <!--[endif]-->

import org.apache.struts.action.Action;

import org.apache.struts.action.ActionForm;

import org.apache.struts.action.ActionForward;

import org.apache.struts.action.ActionMapping;

import org.hibernate.criterion.DetachedCriteria;

import org.hibernate.criterion.Order;

import org.springframework.web.context.WebApplicationContext;

import org.springframework.web.context.support.WebApplicationContextUtils;

<!--[if !supportEmptyParas]--> <!--[endif]-->

import com.jh.xh.common.PaginationSupport;

import com.jh.xh.hibernate.pojo.InfoTab;

import com.jh.xh.spring.service.UserManager;

<!--[if !supportEmptyParas]--> <!--[endif]-->

/**

* Creation date: 03-22-2007

*/

public class QueryToDayInfoAction extends Action {

private UserManager userManager;

<!--[if !supportEmptyParas]--> <!--[endif]-->

public UserManager getUserManager() {

return userManager;

}

<!--[if !supportEmptyParas]--> <!--[endif]-->

public void setUserManager(UserManager userManager) {

this.userManager = userManager;

}

<!--[if !supportEmptyParas]--> <!--[endif]-->

public ActionForward execute(ActionMapping mapping, ActionForm form,

HttpServletRequest request, HttpServletResponse response) {

<!--[if !supportEmptyParas]--> <!--[endif]-->

WebApplicationContext wac = WebApplicationContextUtils

.getRequiredWebApplicationContext(this.getServlet()

.getServletContext());

<!--[if !supportEmptyParas]--> <!--[endif]-->

this.userManager = (UserManager) wac.getBean("userManager");

<!--[if !supportEmptyParas]--> <!--[endif]-->

DetachedCriteria detachedCriteria = DetachedCriteria

.forClass(InfoTab.class);

detachedCriteria.addOrder(Order.desc("id"));

<!--[if !supportEmptyParas]--> <!--[endif]-->

String _startIndex; // 当前页;

_startIndex = (String) request.getParameter("startIndex");

<!--[if !supportEmptyParas]--> <!--[endif]-->

int startIndex;

<!--[if !supportEmptyParas]--> <!--[endif]-->

if (_startIndex == null) {

startIndex = 0;

} else {

startIndex = Integer.parseInt(_startIndex);

}

<!--[if !supportEmptyParas]--> <!--[endif]-->

PaginationSupport ps = userManager.findPageByCriteria(detachedCriteria,

PaginationSupport.PAGESIZE, startIndex);

request.setAttribute("ps", ps);

<!--[if !supportEmptyParas]--> <!--[endif]-->

return mapping.findForward("todayinfolist");

}

<!--[if !supportEmptyParas]--> <!--[endif]-->

}

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

action-servlet.xml 配置文件

<!--[if !supportEmptyParas]--> <!--[endif]-->

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"

"http://www.springframework.org/dtd/spring-beans.dtd">

<!--[if !supportEmptyParas]--> <!--[endif]-->

<beans>

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!-- Define Struts Actions here -->

<!--[if !supportEmptyParas]--> <!--[endif]-->

<bean name="/queryToDayInfo"

class="com.jh.xh.action.QueryToDayInfoAction" singleton="false">

<property name="userManager">

<ref bean="userManager" />

</property>

</bean>

<!--[if !supportEmptyParas]--> <!--[endif]-->

</beans>

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

struts-config.xml 配置文件

<!--[if !supportEmptyParas]--> <!--[endif]-->

<action path="/queryToDayInfo" scope="request"

type="org.springframework.web.struts.DelegatingActionProxy"

validate="false">

<forward name="todayinfolist" path="/todayinfolist.jsp" />

</action>

<!--[if !supportEmptyParas]--> <!--[endif]-->

<plug-in

className="org.springframework.web.struts.ContextLoaderPlugIn">

<set-property property="contextConfigLocation"

value="/WEB-INF/applicationContext.xml,/WEB-INF/action-servlet.xml" />

</plug-in>

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

web.xml 文件配置

<!--[if !supportEmptyParas]--> <!--[endif]-->

<context-param>

<param-name>contextConfigLocation</param-name>

<param-value>/WEB-INF/applicationContext.xml</param-value>

</context-param>

<!--[if !supportEmptyParas]--> <!--[endif]-->

<listener>

<listener-class>

org.springframework.web.context.ContextLoaderListener

</listener-class>

</listener>

<!--[if !supportEmptyParas]--> <!--[endif]-->

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019/09/14 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档