請教open session in view

sha1979發表於2005-08-30
剛剛接觸Spring,我想做個練習,但總出錯;
struts1.1 + hibernate3+spring1.2.1+Tomcat5
我想使用open session in view模式
hibernate中以設定成lazy="true"。
抱錯:session 以關閉
配置如下

web.xml
?xml version="1.0" encoding="UTF-8"?
!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"
web-app
display-name wish /display-name
context-param
param-name contextConfigLocation /param-name
param-value /WEB-INF/applicationContext.xml /param-value
/context-param
filter
filter-name hibernateFilter /filter-name
filter-class org.springframework.orm.hibernate3.support.OpenSessionInViewFilter /filter-class
init-param
param-name singleSession /param-name
param-value false /param-value
/init-param
/filter
filter-mapping
filter-name hibernateFilter /filter-name
url-pattern *.do /url-pattern
/filter-mapping
listener
listener-class org.springframework.web.context.ContextLoaderListener /listener-class
/listener
servlet
servlet-name action /servlet-name
servlet-class org.apache.struts.action.ActionServlet /servlet-class
init-param
param-name config /param-name
param-value /WEB-INF/struts-config.xml /param-value
/init-param
init-param
param-name debug /param-name
param-value 2 /param-value
/init-param
init-param
param-name application /param-name
param-value ApplicationResources /param-value
/init-param
load-on-startup 2 /load-on-startup
/servlet
servlet-mapping
servlet-name action /servlet-name
url-pattern *.do /url-pattern
/servlet-mapping
.........................
...........................
/web-app

struts-config.xml如下
?xml version="1.0" encoding="UTF-8"?
!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"

"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd"
struts-config
form-beans
form-bean name="lazyForm" type="sixhero.actionForm.LazyForm" /
/form-beans
action-mappings
action name="lazyForm" path="/test/lazyAction" scope="request"

type="org.springframework.web.struts.DelegatingActionProxy"
forward name="ok" path="/test/ok.jsp" /
forward name="no" path="/test/no.jsp" /
/action
/action-mappings
message-resources parameter="ApplicationResources" /
plug-in className="org.springframework.web.struts.ContextLoaderPlugIn"
set-property property="contextConfigLocation" value="/WEB-INF/applicationContext.xml" /
/plug-in

/struts-config


ok.jsp如下

%@ page contentType="text/html; charset=GB2312" %
%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %
%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %
%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %
%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %
%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %
%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %
html
head
title
ok
/title
/head
body bgcolor="ffffff"

logic:notEmpty name="list"
logic:iterate id="temp" name="list"
bean:write name="temp" property="UserName"/
br
bean:write name="temp" property="forumDescript"/
br


br
bean:write name="temp" property="Order.name" filter="true"/
br
br


/logic:iterate

/logic:notEmpty
/body
/html


Order.name總是抱錯




相關文章