隨筆-153  評(píng)論-235  文章-19  trackbacks-0
           

              Velocity 郵件模板在Spring 中發(fā)郵件報(bào)unable to find resource 'WEB-INF/test.vm' in any resource loader導(dǎo)常。配置如下:

              <bean id="templateMail" class="com.chenlb.mail.VelocityTemplateMessage">
                  
          <property name="javaMailSender" ref="mailSender"></property>
                  
          <property name="from" value="${mail.from}"></property>
                  
          <property name="encoding" value="UTF-8"></property>
                  
          <property name="templateLocation" value="WEB-INF/test.vm"></property>
                  
          <property name="velocityEngine">
                      
          <bean class="org.springframework.ui.velocity.VelocityEngineFactoryBean"></bean>
                  
          </property>
                  
          <property name="title" value="www.aygfsteel.com/chenlb"></property>
              
          </bean>

          郵件內(nèi)容生成如下:
          VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, templateLocation, encoding, model);

          但導(dǎo)常,說(shuō)不可用的資源。

          說(shuō)明:VelocityEngineUtils.mergeTemplateIntoString()里的templateLocation的文件,不會(huì)像Spring一樣找。然后就看Spring 的 VelocityEnginFactory API和試,最后發(fā)現(xiàn)<bean class="org.springframework.ui.velocity.VelocityEngineFactoryBean"></bean>
          單獨(dú)定義,并配置resourceLoaderPath屬性即可搞定。

          配置后的:
              <bean id="velocityEngine" class="org.springframework.ui.velocity.VelocityEngineFactoryBean">
                  
          <property name="resourceLoaderPath" value="WEB-INF/"></property>
              
          </bean>
              
              
          <bean id="templateMail" class="com.chenlb.mail.VelocityTemplateMessage">
                  
          <property name="javaMailSender" ref="mailSender"></property>
                  
          <property name="from" value="${mail.from}"></property>
                  
          <property name="encoding" value="UTF-8"></property>
                  
          <property name="templateLocation" value="test.vm"></property>
                  
          <property name="velocityEngine" ref="velocityEngine"></property>
                  
          <property name="title" value="wwww.aygfsteel.com/chenlb"></property>
              
          </bean>

          resourceLoaderPath是由Spring設(shè)置過(guò)的,跟平常的(Spring)文件資源一樣方式引用,Spring真的太方便了。
          posted @ 2007-08-18 02:11 流浪汗 閱讀(3741) | 評(píng)論 (0)編輯 收藏

              由于沒(méi)有用MVC框架,所以在view層的不能由Spring依賴注入,現(xiàn)在我jsp頁(yè)面又想引用Spring管理的Bean,那怎么辦。用WebApplicationContextUtils幫助類。jsp頁(yè)面如下:

          <%@ page language="java" pageEncoding="UTF-8"%>
          <%@ page import="org.springframework.web.context.support.WebApplicationContextUtils" %>
          <%@ page import="org.springframework.web.context.WebApplicationContext" %>
          <%
              WebApplicationContext wac 
          = WebApplicationContextUtils.getRequiredWebApplicationContext(this.getServletContext());
          %>
          posted @ 2007-08-13 17:22 流浪汗 閱讀(1018) | 評(píng)論 (0)編輯 收藏
          oracle 沒(méi)有boolean,mysql用bit(1)而oracle可以用char(1) check(...(0,1))字段,
          如:
          create table a ( a char(1check (a in(0,1)))

          然后JDBC用getBoolean()可以返回正確的結(jié)果。

          JDBC我用ojdbc14.jar
          posted @ 2007-08-13 16:58 流浪汗 閱讀(2999) | 評(píng)論 (0)編輯 收藏

          jdbc:oracle:driver_type:[username/password]@database_specifier

          drive_type有thin和oci

          如:
          jdbc:oracle:thin:@localhost:1521:my_db
          posted @ 2007-08-13 15:45 流浪汗 閱讀(9941) | 評(píng)論 (1)編輯 收藏

             HTML的文檔聲明讓浪費(fèi)了一個(gè)小時(shí).,我用一網(wǎng)上找到鼠標(biāo)提示,平常用的好的,今天在一個(gè)N久前創(chuàng)建的HTML文件里加個(gè)鼠標(biāo)提示,提示的樣子變了。跟IE的錯(cuò)誤提示,老是看它的提示代碼,有沒(méi)有可以改進(jìn)的。最后沒(méi)折了,刪除了文檔聲明。就行了。真是郁悶。以前也個(gè)輸入框也變樣了,刪除文檔聲明就行了。文檔聲明對(duì)鼠標(biāo)提示也有效,郁悶,郁悶。。。浪費(fèi)了一個(gè)小時(shí)

          下面的文檔聲明是Dreamweaver8生成的。



              <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<html xmlns="posted @ 2007-08-07 22:23 流浪汗 閱讀(626) | 評(píng)論 (0)編輯 收藏


                在Tomcat的conf/web.xml文件里把listings值改為false
          如:

              <servlet>
                  
          <servlet-name>default</servlet-name>
                  
          <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
                  
          <init-param>
                      
          <param-name>debug</param-name>
                      
          <param-value>0</param-value>
                  
          </init-param>
                  
          <init-param>
                      
          <param-name>listings</param-name>
                      
          <param-value>false</param-value>
                  
          </init-param>
                  
          <load-on-startup>1</load-on-startup>
              
          </servlet>
          posted @ 2007-08-07 13:58 流浪汗 閱讀(1311) | 評(píng)論 (4)編輯 收藏
               摘要:       先描述下我的環(huán)境eclipse 3.2.2+myeclilpse 5.5.1Spring 2.0.6,Ehcache用spring2.0.6帶的1.2.4加入的jarSpring.jarcommons-logging.jarehcache-1.2.4.jarlog4j-1.2.14.jarjunit3.8.1.jar ...  閱讀全文
          posted @ 2007-08-02 14:35 流浪汗 閱讀(3145) | 評(píng)論 (1)編輯 收藏
                想學(xué)習(xí)緩存框架已經(jīng)很久了,一直沒(méi)做到,可能是太忙了.現(xiàn)在開始學(xué)習(xí)了,

          1.下載
          我下的是1.2.4
          下載地址: http://sourceforge.net/project/showfiles.php?group_id=93232

          2.看了文檔,有幾個(gè)核心的類要記住
          CacheManager   緩存管理器
          Cache   緩存
          Element   被緩存的內(nèi)容

          CacheManager 可以是單例,也可以是instance
          CacheManager.create();返回單例
          直接new 是instance

          添加Cache
          CacheManager singletonManager = CacheManager.create();
          Cache memoryOnlyCache = new Cache("testCache", 5000, false, false, 5, 2);
          manager.addCache(memoryOnlyCache);

          得到Cache
          Cache test = singletonManager.getCache("testCache");


          Cache的參數(shù)可以放到屬性文件里,我比較關(guān)注這點(diǎn)

          在下載來(lái)的包里有ehcache.xml文件,

          講不清楚還是寫個(gè)例子好,看我例子的文章: http://www.aygfsteel.com/chenlb/archive/2007/08/02/133988.html


          官方手冊(cè)
          http://ehcache.sourceforge.net/EhcacheUserGuide.html



          posted @ 2007-08-02 14:19 流浪汗 閱讀(1458) | 評(píng)論 (0)編輯 收藏
                我的頁(yè)面都是UTF-8,所有請(qǐng)求中文都沒(méi)有問(wèn)題,但一個(gè)表單里加了 fileupload 后,就亂碼了。用到fileItem.getString();方法,結(jié)果亂碼。網(wǎng)上找了下用getString("UTF-8");就可了。^_^
             
                fileupload是commons-fileupload-1.0.jar的

                多謝。http://argen.bokee.com/viewdiary.14753538.html
          posted @ 2007-07-26 17:13 流浪汗 閱讀(1011) | 評(píng)論 (1)編輯 收藏
               在Tomcat根式目錄的 conf/server.xml文件中,找<Connector port="8080" />,在里面加uRIEncoding="gbk"


              <Connector port="8080" maxHttpHeaderSize="8192"
                         maxThreads
          ="150" minSpareThreads="25" maxSpareThreads="75"
                         enableLookups
          ="false" redirectPort="8443" acceptCount="100"
                         connectionTimeout
          ="20000" disableUploadTimeout="true" uRIEncoding="gbk"/>
          posted @ 2007-07-17 20:37 流浪汗 閱讀(2920) | 評(píng)論 (0)編輯 收藏
          僅列出標(biāo)題
          共16頁(yè): First 上一頁(yè) 7 8 9 10 11 12 13 14 15 下一頁(yè) Last 
          主站蜘蛛池模板: 宝鸡市| 连州市| 客服| 沭阳县| 海林市| 收藏| 巢湖市| 庄河市| 宁阳县| 辽阳市| 临夏市| 金阳县| 隆回县| 亳州市| 凤凰县| 汾西县| 福安市| 囊谦县| 榆社县| 广水市| 赤水市| 乌海市| 广宁县| 恩施市| 都昌县| 北京市| 深水埗区| 华蓥市| 乐清市| 河池市| 沙湾县| 精河县| 望谟县| 疏勒县| 昔阳县| 和林格尔县| 克拉玛依市| 会宁县| 湘西| 九龙城区| 密山市|