<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[版面 "开发技术" 中的最新主题]]></title>
		<link>http://www.mydwbi.com/forums/show/18.page</link>
		<description><![CDATA[在版面 "开发技术" 中最新讨论的主题]]></description>
		<generator>JForum - http://www.jforum.net</generator>
			<item>
				<title>如何將再編輯過的帖再標是為未閱讀</title>
				<description><![CDATA[ 如主題,<br /> 這樣可以方便查閱被編輯過的舊帖...]]></description>
				<guid isPermaLink="true">http://www.mydwbi.com/posts/preList/1405/4990.page</guid>
				<link>http://www.mydwbi.com/posts/preList/1405/4990.page</link>
				<pubDate><![CDATA[Thu, 2 Jun 2011 03:23:33]]> GMT</pubDate>
				<author><![CDATA[ sssss]]></author>
			</item>
			<item>
				<title>二次开发问题请教</title>
				<description><![CDATA[ 在修改Jforum的过程中，点击后台管理进去之后，找不到修改后台主页面标题(title)的页面，还是显示默认的“Jforum-Administrator interface”,希望知道的大虾不惜赐教。thk]]></description>
				<guid isPermaLink="true">http://www.mydwbi.com/posts/preList/929/4357.page</guid>
				<link>http://www.mydwbi.com/posts/preList/929/4357.page</link>
				<pubDate><![CDATA[Sun, 21 Nov 2010 22:15:23]]> GMT</pubDate>
				<author><![CDATA[ aa]]></author>
			</item>
			<item>
				<title>jforum论坛里的时间格式修改</title>
				<description><![CDATA[ 按了一个jforum论坛，现在默认的时间格式是dd/mm/yyyy<br /> 请问一下，修改什么地方可以把格式变为yyyy-mm-dd,就像这个论坛的格式一样。<br /> <br /> 找了半天也没有找到地方，先谢谢大家了。 ;shaxiao;]]></description>
				<guid isPermaLink="true">http://www.mydwbi.com/posts/preList/771/3912.page</guid>
				<link>http://www.mydwbi.com/posts/preList/771/3912.page</link>
				<pubDate><![CDATA[Fri, 30 Apr 2010 02:24:10]]> GMT</pubDate>
				<author><![CDATA[ yubq2010]]></author>
			</item>
			<item>
				<title>招兼职framework讲师</title>
				<description><![CDATA[ 本公司现招兼职framework/net讲师，待遇<br /> 优，可周末，有意者请联系我<br /> QQ:496397940，邮<br /> 件:hailang869@163.com <br /> ]]></description>
				<guid isPermaLink="true">http://www.mydwbi.com/posts/preList/764/3872.page</guid>
				<link>http://www.mydwbi.com/posts/preList/764/3872.page</link>
				<pubDate><![CDATA[Thu, 8 Apr 2010 03:22:15]]> GMT</pubDate>
				<author><![CDATA[ hehe123]]></author>
			</item>
			<item>
				<title>个性签名如何设置 图片</title>
				<description><![CDATA[  :kuqi:<br /> <br /> 先谢过～]]></description>
				<guid isPermaLink="true">http://www.mydwbi.com/posts/preList/702/3667.page</guid>
				<link>http://www.mydwbi.com/posts/preList/702/3667.page</link>
				<pubDate><![CDATA[Mon, 30 Nov 2009 01:51:59]]> GMT</pubDate>
				<author><![CDATA[ xxw]]></author>
			</item>
			<item>
				<title>请问CEO论坛背景颜色怎么改</title>
				<description><![CDATA[ 我windows主题 窗口 的颜色设置不是 白色。但是希望这个论坛的背景色为白色。发现版主的这个论坛背景色是白色，可否赐教？我目前的效果图像附件中那样]]></description>
				<guid isPermaLink="true">http://www.mydwbi.com/posts/preList/701/3664.page</guid>
				<link>http://www.mydwbi.com/posts/preList/701/3664.page</link>
				<pubDate><![CDATA[Sun, 29 Nov 2009 23:03:35]]> GMT</pubDate>
				<author><![CDATA[ xxw]]></author>
			</item>
			<item>
				<title>jforum添加版面分类问题</title>
				<description><![CDATA[ 因为是试用，新建版面分类时，admin没有查看权限，general有查看权限。现在我用admin登录，后台管理里面不出现那个版面分类，无法删除，怎么解决哦？]]></description>
				<guid isPermaLink="true">http://www.mydwbi.com/posts/preList/699/3657.page</guid>
				<link>http://www.mydwbi.com/posts/preList/699/3657.page</link>
				<pubDate><![CDATA[Wed, 25 Nov 2009 21:16:07]]> GMT</pubDate>
				<author><![CDATA[ xxw]]></author>
			</item>
			<item>
				<title>先测试一下</title>
				<description><![CDATA[ [img]upload/2009/5/3/101ad708e5a0b9504601360cb3bb70e4_2893.jpg_[/img]测[b]试[/b]]]></description>
				<guid isPermaLink="true">http://www.mydwbi.com/posts/preList/563/3069.page</guid>
				<link>http://www.mydwbi.com/posts/preList/563/3069.page</link>
				<pubDate><![CDATA[Sun, 3 May 2009 22:00:49]]> GMT</pubDate>
				<author><![CDATA[ zhizunyue]]></author>
			</item>
			<item>
				<title>版主论坛源码能给份不?</title>
				<description><![CDATA[ 喜欢你这个论坛,能给个源码不,不要JForum的. ;yachi; ]]></description>
				<guid isPermaLink="true">http://www.mydwbi.com/posts/preList/475/2641.page</guid>
				<link>http://www.mydwbi.com/posts/preList/475/2641.page</link>
				<pubDate><![CDATA[Tue, 16 Dec 2008 22:55:00]]> GMT</pubDate>
				<author><![CDATA[ test23]]></author>
			</item>
			<item>
				<title>谢谢lynx286，jforum的附件支持gif了，怎样让头像也支持gif啊</title>
				<description><![CDATA[ 谢谢了 ;gao; <br /> <br /> 比如说我现在的头像就是一个gif动画]]></description>
				<guid isPermaLink="true">http://www.mydwbi.com/posts/preList/471/2631.page</guid>
				<link>http://www.mydwbi.com/posts/preList/471/2631.page</link>
				<pubDate><![CDATA[Tue, 9 Dec 2008 19:40:16]]> GMT</pubDate>
				<author><![CDATA[ fly]]></author>
			</item>
			<item>
				<title>jforum论坛的表情支持gif，为什么附件不支持gif动画呢</title>
				<description><![CDATA[  :kuqi: <br /> <br /> 请看：<br /> <a class="snap_shots" href="http://www.mydwbi.com/posts/list/0/469.page" target="_blank" rel="nofollow">http://www.mydwbi.com/posts/list/0/469.page</a>]]></description>
				<guid isPermaLink="true">http://www.mydwbi.com/posts/preList/470/2613.page</guid>
				<link>http://www.mydwbi.com/posts/preList/470/2613.page</link>
				<pubDate><![CDATA[Sun, 7 Dec 2008 04:16:55]]> GMT</pubDate>
				<author><![CDATA[ fly]]></author>
			</item>
			<item>
				<title>关于jforum SSO的疑问！</title>
				<description><![CDATA[ 说jforum 支持sso，我看了interface SSO，authenticateUser的方法只是返回了String，那对于验证通过的用户，论坛是怎么得到他的基本信息的，在线留言还能用吗？我也看了网上的一些实现，并没有讲到这些，后面我也会去自己做一些test，但是还是先问一下lynx286，是一个什么样的机制。<br /> ]]></description>
				<guid isPermaLink="true">http://www.mydwbi.com/posts/preList/407/2279.page</guid>
				<link>http://www.mydwbi.com/posts/preList/407/2279.page</link>
				<pubDate><![CDATA[Tue, 14 Oct 2008 03:22:50]]> GMT</pubDate>
				<author><![CDATA[ ibudo]]></author>
			</item>
			<item>
				<title>请问哪里可以在JFORM里增加昵称并显示出来?</title>
				<description><![CDATA[ 请问哪里可以在JFORM里增加昵称并显示出来?[size=18][/size]]]></description>
				<guid isPermaLink="true">http://www.mydwbi.com/posts/preList/397/2210.page</guid>
				<link>http://www.mydwbi.com/posts/preList/397/2210.page</link>
				<pubDate><![CDATA[Sat, 4 Oct 2008 02:39:16]]> GMT</pubDate>
				<author><![CDATA[ g7235723]]></author>
			</item>
			<item>
				<title>开源论坛</title>
				<description><![CDATA[ 斑竹，这个论坛是开源的吗？很喜欢这个风格，请问是如何搭建的。谢谢.]]></description>
				<guid isPermaLink="true">http://www.mydwbi.com/posts/preList/203/1101.page</guid>
				<link>http://www.mydwbi.com/posts/preList/203/1101.page</link>
				<pubDate><![CDATA[Tue, 24 Jun 2008 18:54:28]]> GMT</pubDate>
				<author><![CDATA[ li_jianmydwbi]]></author>
			</item>
			<item>
				<title>最快速度把自己网站变灰代码!--为地震中死难者默哀!!!</title>
				<description><![CDATA[ 只支持IE <br /> html,body,p,div,form{filter:gray;color:gray;} <br /> <br /> 在CSS文件或style中加入，同时请注意优先级问题，IE浏览器的巨大优势在这种快速应变事件中终于显示出来了~ <br /> UPDATA：用“*”会引发用相对、决对定位的按纽点击不了，所有改为html,body,p,div,form <br /> <br /> 有一些网站FLASH动画的颜色不能被CSS滤镜控制，可以在FLASH代码的 &lt;object …&gt;和 &lt;/object&gt;之间插入： <br /> <br /> &lt;param value="false" name="menu"/&gt; <br /> &lt;param value="opaque" name="wmode"/&gt;]]></description>
				<guid isPermaLink="true">http://www.mydwbi.com/posts/preList/127/574.page</guid>
				<link>http://www.mydwbi.com/posts/preList/127/574.page</link>
				<pubDate><![CDATA[Mon, 19 May 2008 03:53:40]]> GMT</pubDate>
				<author><![CDATA[ lynx286]]></author>
			</item>
			<item>
				<title>jforum论坛二次开发--小修小改汇总贴</title>
				<description><![CDATA[ ***************************************** <br /> lynx286原创, 首发[url]www.mydwbi.com[/url] <br /> [url]http://www.mydwbi.com/posts/list/0/103.page[/url]<br /> 欢迎转贴, 但转贴请不要删除此段版权说明. <br /> *****************************************<br /> <br /> [list][size=18][color=blue]将会员列表改成按id排序（新注册用户排前面）[/color][/size][/list]<br /> <br /> web-inf\config\database\generic\generic_queries.sql<br /> <br /> 将58-59行  "order by username"  改成 "order by user_id desc"<br /> <br /> <br /> [list][size=18][color=blue]添加网站地图[/color][/size][/list]<br /> -生成sitemap.xml<br /> jforum 的url后缀是.page不是常规的.htm .html .asp .jsp 所以很多sitemap.xml builder不能识别jforum中的链接,所以自动生成不了sitemap.xml(本人猜想是这个原因),后来找半天找到一个工具叫SOFTplus GSiteCrawler的可以自定义页面后缀,从而自动生成sitemap.xml.<br /> <br /> -添加国际化属性<br /> zh_CN.properties中最后添加:mydwbi.sitemap=\u7f51\u7ad9\u5730\u56fe<br /> <br /> -添加入口链接<br /> 在forum_list.htm中第181行下添加:<br /> [code]<br /> &lt;td&gt;&nbsp;&nbsp;&lt;/td&gt;<br /> &lt;td align="center" width="20"&gt;<img   />&lt;/td&gt;<br /> &lt;td&gt;&lt;span class="gensmall"&gt;&lt;ａ ｈｒｅｆ="${contextPath}/sitemap.xml"&gt;${I18n.getMessage("mydwbi.sitemap")}</a>&lt;/span&gt;&lt;/td&gt;<br /> [/code]<br /> <br /> <br /> <br /> <br /> [list][size=18][color=blue]修改版权信息[/color][/size][/list]<br /> 修改bottom.htm 11行.<br /> <br /> <br /> [list][size=18][color=blue]将发贴时&quot;pool&quot;,&quot;attachments&quot;,&quot;options&quot;改成中文[/color][/size][/list]<br /> -添加国际化属性<br /> mydwbi.Options=\u9009\u9879<br /> mydwbi.Pool=\u6295\u7968<br /> mydwbi.Attach=\u9644\u4ef6<br /> <br /> -修改模板<br /> 将post_form.htm中第369,372,375行&quot;pool&quot;,&quot;attachments&quot;,&quot;options&quot;改成:<br /> ${I18n.getMessage(&quot;mydwbi.Options&quot;)}<br /> ${I18n.getMessage(&quot;mydwbi.Pool&quot;)}<br /> ${I18n.getMessage(&quot;mydwbi.Attach&quot;)}<br /> <br /> [list][size=18][color=blue]让发贴的表情符号列表多显示几个表情[/color][/size][/list]<br /> 修改post_form.htm261行，改成：&lt;#if (count &lt; 32)&gt;<br /> <br /> <br /> [list][size=18][color=blue]特定用户显示ip[/color][/size][/list]<br /> post_show_user_inc.htm36，37行改成：<br /> [code]<br /> &lt;#if (post.userIp?exists && isModerator) || (post.userIp?exists && session.username = &quot;lynx286&quot;)&gt;<br /> ${I18n.getMessage(&quot;PostShow.userIP&quot;)}: <a href="http://whois.domaintools.com/${post.userIp}"  target="_blank">${post.userIp}</a>[/code]<br /> <br /> 即如果当前登陆用户为该版版主或用户名为lynx286,就显示发贴人ip地址<br /> <br /> <br /> [list][size=18][color=blue]进入板块后显示主题列表页面发表人栏显示帖子发表时间[/color][/size][/list]<br /> 进入板块后显示主题列表页面指： /forums/show/xxxx.page  页面<br /> forum_show.htm页面224行改成：<br /> [code]&lt;span class="postdetails"&gt;${topic.firstPostTime}<br /><a >[/code]<br /> 176行改成：width=140<br /> <br /> <br /> [list][size=18][color=blue]bmp图片也显示缩略图[/color][/size][/list]<br /> 用户经常用print screen键拷贝屏幕图片，并发到帖子上，是bmp格式，不能显示缩略图，要下载才能看，不太方便。这里改一下可显示缩略图 。<br /> AttachmentCommon.java  254行添加："bmp".equals(extension) ||]]></description>
				<guid isPermaLink="true">http://www.mydwbi.com/posts/preList/103/394.page</guid>
				<link>http://www.mydwbi.com/posts/preList/103/394.page</link>
				<pubDate><![CDATA[Mon, 12 May 2008 02:16:45]]> GMT</pubDate>
				<author><![CDATA[ lynx286]]></author>
			</item>
			<item>
				<title>jforum论坛二次开发--显示版主</title>
				<description><![CDATA[ ***************************************** <br /> lynx286原创, 首发www.mydwbi.com <br /> <a class="snap_shots" href="http://www.mydwbi.com/posts/list/0/45.page" target="_blank" rel="nofollow">http://www.mydwbi.com/posts/list/0/45.page</a><br /> 欢迎转贴, 但转贴请不要删除此段版权说明. <br /> ***************************************** <br /> <br /> jforum论坛是很流行的java开源论坛,但不支持版主.网友可以查查其他的jforum论坛都没有版主, 这种论坛貌似很不适合中国国情,本人在这里介绍一个显示版主的方法.<br /> <br /> 1. 为每个板块添加一个群组, 将版主的群组属性改成此群组.<br /> 2. 板块的审核属性用默认的"不审核", 原来只有设置成"审核状态"才显示版主,但这样每发一个帖子都要审核,不好.<br /> 3. 删除forum_list.htm 第51(57)行那个if语句即可. <br /> <br /> 其实过程非常简单, 但是网上都没有人研究,尝试解决这个问题.<br /> ]]></description>
				<guid isPermaLink="true">http://www.mydwbi.com/posts/preList/45/152.page</guid>
				<link>http://www.mydwbi.com/posts/preList/45/152.page</link>
				<pubDate><![CDATA[Thu, 1 May 2008 07:00:10]]> GMT</pubDate>
				<author><![CDATA[ lynx286]]></author>
			</item>
			<item>
				<title>jforum论坛二次开发--添加页面</title>
				<description><![CDATA[ *****************************************<br /> lynx286原创, 首发www.mydwbi.com<br /> http://www.mydwbi.com/posts/list/44.page<br /> 欢迎转贴, 但转贴请不要删除此段版权说明.<br /> *****************************************<br /> <br /> 如添加本网站联系我们,广告投放等两个页面.<br /> <br /> 1. 在modulesMapping.properties文件中添加:mydwbi=com.mydwbi.MydwbiAction<br />     此文件用来映射模块名.即添加一个叫mydwbi的模块.<br /> <br /> 2. 在templatesMapping.properties文件中添加:<br />       mydwbi.contact = contact.htm<br />          mydwbi.advertisement = advertisement.htm<br />     此文件映射action和result 模板的关系,学过freemarker的可能会好理解些.<br /> <br /> 3. 在urlPattern.properties中添加:<br />        mydwbi.contact.0 =<br />        mydwbi.advertisement.0 =<br />     此文件设置每个action参数.我们这个action无参数.<br /> <br /> 4. 修改net.jforum.util.preferences.TemplateKeys类,添加:<br />            public static final String MYDWBI_CONTACT = "mydwbi.contact";<br /> 	public static final String MYDWBI_AD = "mydwbi.advertisement";<br /> <br /> 5. 新建一个类:com.mydwbi.MydwbiAction<br /> [code]package com.mydwbi;<br /> <br /> import net.jforum.Command;<br /> import net.jforum.util.preferences.TemplateKeys;<br /> <br /> public class MydwbiAction extends Command {<br /> 	public void list() {<br /> 	}<br /> <br /> 	public void contact() {<br /> 		this.setTemplateName(TemplateKeys.MYDWBI_CONTACT);<br /> 	}<br /> <br /> 	public void advertisement() {<br /> 		this.setTemplateName(TemplateKeys.MYDWBI_AD);<br /> 	}<br /> <br /> }<br /> [/code]<br /> <br /> 6. 修改jforum\templates\default\header.htm, 添加:<br />     [code]<a   /mydwbi/contact")}"><img    />${I18n.getMessage("mydwbi.contact")}</a>&nbsp; &lt;/span&gt;<br /> 										<a   /mydwbi/advertisement")}"><img    />${I18n.getMessage("mydwbi.Advertisement")}</a>&nbsp; &lt;/span&gt;<br /> 									[/code]<br /> <br /> 7. 添加两个文件contact.htm,advertisement.htm 在目录:jforum\templates\default\下:<br /> contact.htm:<br /> [code]&lt;#include &quot;header.htm&quot;/&gt;<br /> &lt;center&gt;<br /> ${I18n.getMessage("mydwbi.contactDesc")}:admin@mydwbi.com<br /> &lt;/center&gt;<br /> &lt;#include &quot;bottom.htm&quot;/&gt;<br /> [/code]<br /> <br /> advertisement.htm <br /> [code]&lt;#include &quot;header.htm&quot;/&gt;<br /> &lt;center&gt;<br /> 	${I18n.getMessage("mydwbi.adDesc")}:admin@mydwbi.com<br /> &lt;/center&gt;<br /> &lt;#include &quot;bottom.htm&quot;/&gt;<br /> [/code]<br /> <br /> 8. 添加国际化文件:<br /> native2ascii -encoding GBK messages.properties messages_ZH.properties<br /> 注意要加-encoding 参数,且参数值不是utf8.<br /> <br /> <br /> 完成!本人较懒, 写的不详细.有问题请跟贴!<br /> ]]></description>
				<guid isPermaLink="true">http://www.mydwbi.com/posts/preList/44/151.page</guid>
				<link>http://www.mydwbi.com/posts/preList/44/151.page</link>
				<pubDate><![CDATA[Thu, 1 May 2008 06:43:32]]> GMT</pubDate>
				<author><![CDATA[ lynx286]]></author>
			</item>
			<item>
				<title>Open Session In View探讨(转)</title>
				<description><![CDATA[ 在没有使用Spring提供的Open Session In View情况下，因需要在service(or Dao)层里把session关闭，所以lazy loading 为true的话，要在应用层内把关系集合都初始化，如 company.getEmployees()，否则Hibernate抛session already closed Exception;    Open Session In View提供了一种简便的方法，较好地解决了lazy loading问题.<br /> <br />     它有两种配置方式OpenSessionInViewInterceptor和OpenSessionInViewFilter(具体参看SpringSide)，功能相同，只是一个在web.xml配置，另一个在application.xml配置而已。<br /> <br />     Open Session In View在request把session绑定到当前thread期间一直保持hibernate session在open状态，使session在request的整个期间都可以使用，如在View层里PO也可以lazy loading数据，如 ${ company.employees }。当View 层逻辑完成后，才会通过Filter的doFilter方法或Interceptor的postHandle方法自动关闭session。<br /> [code]&lt;beans&gt; <br />   &lt;bean name="openSessionInViewInterceptor" class="org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor"&gt; <br /> <br />        &lt;property name="sessionFactory"&gt; <br />                 &lt;ref bean="sessionFactory"/&gt;<br />            &lt;/property&gt; <br /> &lt;/bean&gt;  <br />  &lt;bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"&gt;     <br />                 &lt;property name="interceptors"&gt; <br />                      &lt;list&gt;<br />                          &lt;ref bean="openSessionInViewInterceptor"/&gt;<br />                    &lt;/list&gt;     <br />                 &lt;/property&gt; <br />               &lt;property name="mappings"&gt; <br />                   ...     <br />               &lt;/property&gt;<br />    &lt;/bean&gt; <br />   ... <br /> &lt;/beans&gt; <br /> [/code]<br /> OpenSessionInViewFilter配置<br /> [code]<br /> &lt;web-app&gt; <br />   ... <br />   &lt;filter&gt;<br />      &lt;filter-name&gt;hibernateFilter&lt;/filter-name&gt;<br />      &lt;filter-class&gt;       org.springframework.orm.hibernate3.support.OpenSessionInViewFilter     &lt;/filter-class&gt;<br />      &lt;!-- singleSession默认为true,若设为false则等于没用OpenSessionInView --&gt;<br />     &lt;init-param&gt;<br />        &lt;param-name&gt;singleSession&lt;/param-name&gt;<br />        &lt;param-value&gt;true&lt;/param-value&gt; <br />       &lt;/init-param&gt;<br />   &lt;/filter&gt;<br />  ...<br />    &lt;filter-mapping&gt;<br />      &lt;filter-name&gt;hibernateFilter&lt;/filter-name&gt;<br />      &lt;url-pattern&gt;*.do&lt;/url-pattern&gt;<br />    &lt;/filter-mapping&gt; ... &lt;/web-app&gt; <br /> [/code]<br /> <br /> 很多人在使用OpenSessionInView过程中提及一个错误：<br /> <br /> [code]<br /> <br /> org.springframework.dao.InvalidDataAccessApiUsageException: <br /> Write operations are not allowed in read-only mode (FlushMode.NEVER) <br /> - turn your Session into FlushMode.AUTO or remove 'readOnly' marker from transaction definition <br /> [/code]<br /> 看看OpenSessionInViewFilter里的几个方法<br /> <br /> [code]<br /> protected void doFilterInternal(HttpServletRequest request,<br /> 			 HttpServletResponse response,<br /> 			 FilterChain filterChain) throws ServletException, IOException {<br /> 			 　SessionFactory sessionFactory = lookupSessionFactory();<br /> 			 　logger.debug("Opening Hibernate Session in OpenSessionInViewFilter");<br /> 			 　Session session = getSession(sessionFactory);<br /> 			 　TransactionSynchronizationManager.bindResource(　<br /> 			 　sessionFactory, new SessionHolder(session));<br /> 			 　try {<br /> 			 　　filterChain.doFilter(request, response);　<br /> 			 }　finally {　<br /> 			 TransactionSynchronizationManager.unbindResource(sessionFactory);<br /> 			 　logger.debug("Closing Hibernate Session in OpenSessionInViewFilter");<br /> 			 　closeSession(session, sessionFactory);<br /> 			 　}<br /> 			 }<br /> <br />  protected Session getSession(SessionFactory sessionFactory)throws DataAccessResourceFailureException {<br />  　Session session = SessionFactoryUtils.getSession(sessionFactory, true);<br />  　session.setFlushMode(FlushMode.NEVER);<br />  　return session;<br />  }<br />  <br />  protected void closeSession(Session session, SessionFactory sessionFactory)throws CleanupFailureDataAccessException {<br />  <br />  　SessionFactoryUtils.closeSessionIfNecessary(session, sessionFactory);<br />  } <br /> [/code]<br /> <br />  可以看到OpenSessionInViewFilter在getSession的时候,会把获取回来的session的flush mode 设为FlushMode.NEVER。然后把该sessionFactory绑定到TransactionSynchronizationManager，使request的整个过程都使用同一个session，在请求过后再接除该sessionFactory的绑定，最后closeSessionIfNecessary根据该session是否已和transaction绑定来决定是否关闭session。在这个过程中，若HibernateTemplate 发现自当前session有不是readOnly的transaction，就会获取到FlushMode.AUTO Session，使方法拥有写权限。<br /> [code]<br /> public static void closeSessionIfNecessary(Session session, SessionFactory sessionFactory)      throws CleanupFailureDataAccessException {<br /> <br />     if (session == null || TransactionSynchronizationManager.hasResource(sessionFactory)) {<br />           return;    <br />      }<br />      <br />    logger.debug("Closing Hibernate session");<br />    <br />    try {<br />          session.close();    <br />    }    catch (JDBCException ex) {      // SQLException underneath    <br />      throw new CleanupFailureDataAccessException("Could not close Hibernate session", ex.getSQLException());   <br />   }    catch (HibernateException ex) {    <br /> <br />   throw new CleanupFailureDataAccessException("Could not close Hibernate session", ex);   <br />    } <br />    <br />   }<br />  [/code]<br /> <br /> 也即是，如果有不是readOnly的transaction就可以由Flush.NEVER转为Flush.AUTO,拥有insert,update,delete操作权限，如果没有transaction，并且没有另外人为地设flush model的话，则doFilter的整个过程都是Flush.NEVER。所以受transaction保护的方法有写权限，没受保护的则没有。<br /> [code]<br /> &lt;bean id="baseTransaction" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"           abstract="true"&gt;<br />          &lt;property name="transactionManager" ref="transactionManager"/&gt;<br />                   &lt;property name="proxyTargetClass" value="true"/&gt;<br />                            &lt;property name="transactionAttributes"&gt;<br />                                         &lt;props&gt;<br />                                                &lt;prop key="get*"&gt;PROPAGATION_REQUIRED,readOnly&lt;/prop&gt;<br />                                                 &lt;prop key="find*"&gt;PROPAGATION_REQUIRED,readOnly&lt;/prop&gt;<br />                                                 &lt;prop key="load*"&gt;PROPAGATION_REQUIRED,readOnly&lt;/prop&gt;<br />                                                 &lt;prop key="save*"&gt;PROPAGATION_REQUIRED&lt;/prop&gt;<br />                                                 &lt;prop key="add*"&gt;PROPAGATION_REQUIRED&lt;/prop&gt;<br />                                                 &lt;prop key="update*"&gt;PROPAGATION_REQUIRED&lt;/prop&gt;<br />                                                 &lt;prop key="remove*"&gt;PROPAGATION_REQUIRED&lt;/prop&gt;<br />                                          &lt;/props&gt;<br />                             &lt;/property&gt;<br /> &lt;/bean&gt;<br /> &lt;bean id="userService" parent="baseTransaction"&gt;<br />          &lt;property name="target"&gt;<br />          &lt;bean class="com.phopesoft.security.service.impl.UserServiceImpl"/&gt;<br />          &lt;/property&gt;<br /> &lt;/bean&gt;<br /> [/code]<br /> <br /> 对于上例，则以save,add,update,remove开头的方法拥有可写的事务，如果当前有某个方法，如命名为importExcel()，则因没有transaction而没有写权限，这时若方法内有insert,update,delete操作的话，则需要手动设置flush model为Flush.AUTO,如<br /> <br /> ssion.setFlushMode(FlushMode.AUTO);<br />   session.save(user);<br />   session.flush(); <br /> <br />    尽管Open Session In View看起来还不错，其实副作用不少。看回上面OpenSessionInViewFilter的doFilterInternal方法代码，这个方法实际上是被父类的doFilter调用的，因此，我们可以大约了解的OpenSessionInViewFilter调用流程: request(请求)-&gt;open session并开始transaction-&gt;controller-&gt;View(Jsp)-&gt;结束transaction并close session.<br /> <br />      一切看起来很正确，尤其是在本地开发测试的时候没出现问题，但试想下如果流程中的某一步被阻塞的话，那在这期间connection就一直被占用而不释放。最有可能被阻塞的就是在写Jsp这步，一方面可能是页面内容大，response.write的时间长，另一方面可能是网速慢，服务器与用户间传输时间久。当大量这样的情况出现时，就有连接池连接不足，造成页面假死现象。<br /> <br /> Open Session In View是个双刃剑，放在公网上内容多流量大的网站请慎用。<br /> ]]></description>
				<guid isPermaLink="true">http://www.mydwbi.com/posts/preList/9/23.page</guid>
				<link>http://www.mydwbi.com/posts/preList/9/23.page</link>
				<pubDate><![CDATA[Thu, 24 Apr 2008 09:28:48]]> GMT</pubDate>
				<author><![CDATA[ JetGeng]]></author>
			</item>
	</channel>
</rss>
