??xml version="1.0" encoding="utf-8" standalone="yes"?> Any existing applications that use the Cancel processing will need to modify their struts-config.xml to set the cancellable property for actions which require it. In Struts 1.2.9 the <set-property> is used to set the cancellable property for an action.... From Struts 1.3.x a new cancellable attribute can be used.... In both Struts 1.2.9 and Struts 1.3.x an exception handler can be configured to handle the InvalidCancelException ---------------------------------------end-----------------------------------------------------
]]>
java 1.4日志U录?/span>java.util.logging.LevelcM定义了下列日志别常?/span>
Ø SERVERQ?/span>表示一个严重失败。常常将有一个伴随的Throwable?/span>
Ø CONFIGQ?/span>为应用配|期间所生成的消息而设计的?/span>
Ø INFOQ?/span>中等优先U。表CZ个构件正在做什么(例如Q监视一Q务的 q行q度Q,但不是用来帮助调试该构g?/span>
Ø FINEQ?/span>跟踪信息。该U别和较低优先的别应该用来帮助调试某些类Q但不应该用来M的说明该应用的工作方式?/span>
Ø FINERQ?/span>详细的跟t信息?/span>
Ø FINESTQ?/span>非常详细的跟t信息?/span>
Log4j?/span>
cM定义了下列日志别常?/span>
Ø FATALQ?/span>表示一个严重失败。导?/span>application的中断?/span>
Ø ERRORQ?/span>表示一个错误事件。可以允?/span>Application可以l箋q行?/span>
Ø WARNQ?/span>表示一个有潜在的危险?/span>
Ø INFOQ?/span>表示一个构件正在做重要q行情况Q信息比较粗p?/span>
Ø DEBUGQ?/span>表示一个构件详l的q行情况Q用于调?/span>Application?/span>
Ø ALLQ?/span>表示U录所有别的日志信息?/span>
Common-logging的日志别分?/span>6U,从低到高分别?/span>traceQ?/span>debugQ?/span>infoQ?/span>warnQ?/span>errorQ?/span>fatal?/span>
Ø FATALQ?/span>表示一个严重失败。导?/span>application的中断?/span>
Ø ERRORQ?/span>表示一个错误事件。可以允?/span>Application可以l箋q行?/span>
Ø WARNQ?/span>表示一个有潜在的危险?/span>
Ø INFOQ?/span>表示一个构件正在做重要q行情况Q信息比较粗p?/span>
Ø DEBUGQ?/span>表示一个构件详l的q行情况Q用于调?/span>Application?/span>
Ø TRACEQ?/span>非常详细的跟t信息,仅仅用于U录该日志而已?br />
]]>
response.addHeader("Content-Disposition","attachment;filename="+filename);
]]>
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* 重复接收用户输入一行命?br />
* @author chenlb 2008-3-11 下午09:24:50
*/
public class UserInput {
public static void main(String[] args) throws IOException {
System.out.println("说明: 输入QUIT退?/span>");
System.out.print("\ninput>");
String inputStr = null;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
while((inputStr = br.readLine()) != null) {
if(inputStr.equals("QUIT")) {
System.exit(0);
}
System.out.println("你输入的? "+inputStr); //处理你的逻辑
System.out.print("\ninput>");
}
}
}
]]>
代码片断Q?br />
DefaultStyledDocument styledDoc = new DefaultStyledDocument(); //javax.swing.text.Document的一个实?/span>
try {
InputStream is = new FileInputStream(new File("data/java.swing.text读RTF文档试.rtf"));
new RTFEditorKit().read(is, styledDoc, 0);
bodyText = new String(styledDoc.getText(0, styledDoc.getLength()).getBytes("ISO8859_1")); //提取文本
} catch (IOException e) {
throw new DocumentHandlerException("不能从RTF中摘录文?", e);
} catch (BadLocationException e) {
throw new DocumentHandlerException("不能从RTF中摘录文?", e);
}
System.out.println(bodyText);
]]>
W试的题目类似地Q一个生产者一ơ生?0个,满了后通知消费者,然后{待。一个消费者品有满了消贏V到I时通知生者,然后{待?br />
那时对等?通知机制没怎么写过Q那ơ笔试应该写的大概对Q想法对Q,但写的wait()和notifyAll()的位|不寏V现在有旉写了这个例子?br />
描述Q生产者一ơ生产N个品,池中辑ֈMq待,通知{待的消费者。消费者有产品消费,到没有时通知生者,然后{待?br />
1.生者:
import java.util.List;
/**
* @author chenlb
*
* 生?<br/>
* 默认产品池大M=20,产品梯阶大小N=5.在生产过E中,池的大小会超q?0,但池中最大应该是M+N-1.
*/
public class Producer implements Runnable {
/**
* 池默认大?br />
*/
public static final int DEFALUT_SIZE = 20;
/**
* 默认一ơ生产的数量
*/
public static final int DEFALUT_STEP_SIZE = 5;
private static int PRODUCER_ID = 0; //生者号
private List<Product> pool = null;
private int size = DEFALUT_SIZE;
private int stepSize = DEFALUT_STEP_SIZE;
private String name = "Producer_"+(++PRODUCER_ID); //生者名
private boolean isRun = true;
/**
* 默认产品池大?0, 默认产品增长梯阶大小5
*/
public Producer(List<Product> pool) {
this.pool = pool;
}
/**
* @param pool
* @param size 池大?br />
*/
public Producer(List<Product> pool, int size) {
this.pool = pool;
this.size = size;
}
/**
* @param pool
* @param size 池大?br />
* @param stepSize 一ơ生产多?br />
*/
public Producer(List<Product> pool, int size, int stepSize) {
this.pool = pool;
this.size = size;
this.stepSize = stepSize;
}
public void run() {
// TODO 生者线E?br />
//int pi = 0;
while(isRun) {//&& pi<10
//pi++;
synchronized (pool) { //同步产品?/span>
if(pool.size() >= size) {
try {
System.out.println(name+" {待!");
pool.wait(); //同步什么就{待什?否则抛出java.lang.IllegalMonitorStateException
} catch (InterruptedException e) {
isRun = false;
System.out.println(name+" thread interrupt!");
}
} else {
for(int i=0; i<stepSize; i++) { //一ơ生产stepSize个?/span>
pool.add(product()); //生产品
}
System.out.println("产品池中? "+pool.size());
pool.notifyAll(); //通知{待的线E?主要用来通知消费? 但生产者线E也会通知?
}
}
try {
System.out.println(name+" 休息1U?");
Thread.sleep(1000); //调试?/span>
} catch (InterruptedException e) {
System.out.println(name+" sleep 1s thread interrupt");
}
}
System.out.println(name+" end! pool size: "+pool.size());
}
private static int P_ID = 0;
/**
* 生产品
* @return 产品
*/
private Product product() {
String name = "product_"+(++P_ID);
System.out.println(this.name+" 生? "+name);
return new Production(name);
}
}
2.消费者:
import java.util.List;
/**
* @author chenlb
*
* 消费?br />
*/
public class Consumer implements Runnable {
private static int C_ID = 0; //消费者ID
private List<Product> pool = null;
private String name = "Consumer_"+(++C_ID);
private boolean isRun = true;
public Consumer(List<Product> pool) {
this.pool = pool;
}
public void run() {
// TODO 消费者线E?br />
//int pi = 0;
while(isRun) {//&& pi<10
//pi++;
synchronized (pool) {
if(pool.size() < 1) {
try {
System.out.println(name+" {待!");
pool.notifyAll(); //通知U程(主要是生产?但也会通知到生产者线E?
pool.wait();
} catch (InterruptedException e) {
isRun = false;
System.out.println(name+" thread interrupt!");
}
} else {
Product p = pool.remove(0); //消费
printProduct(p);
}
}
try {
Thread.sleep(1000); //调试?/span>
} catch (InterruptedException e) {
System.out.println(name+" sleep 1s thread interrupt");
}
}
System.out.println(name+" end! pool size: "+pool.size());
}
private void printProduct(Product p) {
System.out.println(name+" 消费? "+p.getName());
}
}
3.Demo
import java.util.LinkedList;
import java.util.List;
/**
* @author chenlb
*
*/
public class Sale {
public static void main(String[] args) {
//链表产品?/span>
List<Product> pool = new LinkedList<Product>();
//两个生?/span>
Producer p1 = new Producer(pool);
Producer p2 = new Producer(pool);
Thread tp1 = new Thread(p1);
Thread tp2 = new Thread(p2);
tp1.start();
tp2.start();
//两个消费?/span>
Consumer c1 = new Consumer(pool);
Consumer c2 = new Consumer(pool);
Thread tc1 = new Thread(c1);
Thread tc2 = new Thread(c2);
tc1.start();
tc2.start();
}
}
注意Q等待时候要用pool.wait()因ؓ同步的是pool。否则会抛出java.lang.IllegalMonitorStateException
^_^
代码下蝲
]]>
部分代码Q?br />
<mkdir dir="${deploy.applet.dir}" />
<javac destdir="${deploy.applet.dir}" encoding="UTF-8" source="1.4"
srcdir="${src.java.dir}" includes="**/applet/**/*.java">
<classpath refid="project.classpath" />
</javac>
</target>
同时也相复制特定子目录下的文件夹Q?br />
<copy todir="${deploy.applet.dir}" preservelastmodified="true">
<fileset dir="${build.java.dir}">
<include name="**/applet/**/*.class"/>
</fileset>
</copy>
</target>
两个都用到inclue方便?
]]>
^_^
]]>
说到?br />
<set-property property="cancellable" value="true"/>
可以解决Q马上复制去试下Q行喔,^_^?br />
---------------------------------引用--------------------------------------
<action path="/fooAction"
input="/foo.jsp"
validate="true">
<set-property property="cancellable" value="true"/>
<forward name="success" path="/bar.jsp"/>
</action>
<action path="/fooAction"
input="/foo.jsp"
validate="true"
cancellable="true">
<forward name="success" path="/bar.jsp"/>
</action>
<action path="/fooAction"
input="/foo.jsp"
validate="true"
cancellable="true">
<forward name="success" path="/bar.jsp"/>
<exception key="errors.cancel"
type="org.apache.struts.action.InvalidCancelException"
path="/foo.jsp"/>
</action>
刚好我用的是struts?.2.9?br />
原文Q?a href="http://www.aygfsteel.com/freiberg/archive/2007/10/20/154384.html">http://www.aygfsteel.com/freiberg/archive/2007/10/20/154384.html
]]>
ClassNotFoundException: org.hibernate.hql.ast.HqlToken 错误weblogic异常退出?
原因:
Hibernate3.0 采用新的ZANTLR的HQL/SQL查询译器,在Hibernate的配|文件中Qhibernate.query.factory_class属性用来选择查询译器?
Q?Q选择Hibernate3.0的查询翻译器Q?
hibernate.query.factory_class= org.hibernate.hql.ast.ASTQueryTranslatorFactory
Q?Q选择Hibernate2.1的查询翻译器
hibernate.query.factory_class= org.hibernate.hql.classic.ClassicQueryTranslatorFactory
Z使用3.0的批量更新和删除功能Q只能选择Q?Q否则不能解释批量更新的语句Q当使用的时候出C不支持条件输入中文的情况。选择Q?Q可以支持输入中文,但没法解释批量更新语句了
在hibernate3中需要用到antlrQ然而这个包在weblogic.jar中已l包含了antrlcdQ就会生一些类加蝲的错误,无法扑ֈ在war或者ear中的hibernate3.jar?
出现q个错误之后Qantlr会调用System.exit()Q这样weblogic׃中止服务?
解决Ҏ(gu):
1.是在hibernate.properties文g中增加属性:hibernate.query.factory_classQ属性的值是org.hibernate.hql.classic.ClassicQueryTranslatorFactoryQ这样就可以解决问题了?
但是部分功能会有问题Q譬?
但本pd扚w删除和更C有问?本系l不采用
2.antlr-2.7.5H3.jar到Weblogic的pre_Classpath :用WinRar或Winzip打开C:\bea\weblogic81\server\lib\weblogic.jar 删除里面的antlr目录, 然后再antlr-2.7.5H3.jar攑֜weblogic.jar的同一目录(?替换之后没做做过严格试,不知是否有后遗?
3. 1、拷贝Hibernate3里带的包antlr-2.7.5H3.jar?WL_HOME%\server\lib?
2、修? mydomain% \ startWebLogic.cmd Q?
在set CLASSPATH之前加上下面一句:
set PRE_CLASSPATH=%WL_HOME%\server\lib\antlr-2.7.5H3.jar;
在set CLASSPATH之后加上下面一句:
set CLASSPATH=%PRE_CLASSPATH%;%CLASSPATH%
一切OKQ?
具体原因可参照此:http://dev2dev.bea.com/blog/pmalani/archive/2005/07/configuring_web.html
我用antlr-2.7.6.jar可以Q我用的hibernate3.2.3ga
出现错误如下:
<
先说下我配置
1.环境Q?/p>
spring 2.0.6Qhibernate 3.2.3Qstruts 1.2.9Qoracle 10.2Qweblogic 8.1.4
jdbc是ojdbc14.jar
2.q接池用DBCP
另外Q没有用OpenSessionInViewFilterQstruts与spring的整合:DelegatingRequestProcessor、action path与bean name同名?/font>
页不过10ơ,服务器就没响应了Q最后出C面的错误的了?/font>
刚用weblogicQ也刚用ssh套餐。郁闗?br />
前天解决了?br />
问题解决Q问题的原因是数据库q接耗尽Q我用HiberanteDaoSupport的getSession()Ҏ(gu)取得Session后没有释放Session?/p>
出问题的代码处(U色部分Q:
用完Session释放后就没事了,调用HiberanteDaoSupport?font face="Arial">releaseSession(session);Ҏ(gu)后即可解冟?/font>
现在正确的代码:
因ؓms word和excel的文档都支持html文本格式Q因此可以先用word或excel做好模版Q另存ؓweb,然后该htmlҎ(gu)jspQ将数据部分动态填入即可,不用很辛苦的调整格式 ?/p>
word面只要在jsp头设|如下指令:
<%@page contentType="application/msword;charset=gb2312" %>
excel如下Q?
<%@page contentType="application/vnd.ms-excel;charset=gb2312" %>