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真的太方便了。
由于沒(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());
%>
oracle 沒(méi)有boolean,mysql用bit(1)而oracle可以用char(1) check(...(0,1))字段,
如:
create table a ( a char(1) check (a in(0,1)))
然后JDBC用getBoolean()可以返回正確的結(jié)果。
JDBC我用ojdbc14.jar
jdbc:oracle:driver_type:[username/password]@database_specifier
drive_type有thin和oci
如:
jdbc:oracle:thin:@localhost:1521:my_db
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>
摘要: 先描述下我的環(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 ...
閱讀全文
想學(xué)習(xí)緩存框架已經(jīng)很久了,一直沒(méi)做到,可能是太忙了.現(xiàn)在開始學(xué)習(xí)了,
1.下載
我下的是1.2.4
下載地址:
http://sourceforge.net/project/showfiles.php?group_id=932322.看了文檔,有幾個(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
我的頁(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
在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"/>