Wednesday, August 09, 2006

Iterate problem in Strtuts

When I transfer a variable of action class to jsp, I find some thing interesting:
If the variable is an Array, then in jsp, I need to write both first two line(1 and 2):

1: <logic:iterate id="dish" name="dishes" type="myPack.Dish">
2: <logic:present name="dish">
3: <bean:write name="dish" property="dishName">
4: </bean:write>
5: </logic:present>
6: </logic:iterate>

then no problem. If I kill the no.2 line then jsp can't find the bean "dish". However, If the value is an ArrayList, no need to write no.2 line, it can work well without no.2 line.
Note: dishes is the variable, it can be transferred from action class in the following way: request.setAttribute("dishes",dishes1);

Monday, July 03, 2006

Add resource mapping into the hibernate.cfg.xml file.

When you want to associate a database table with Hibernate, you must remember to add resource mapping, something like:< resource="myPack/Category.hbm.xml">, into the hibernate.cfg.xml file. Otherwise, the data from this table can't be found.

Tuesday, June 06, 2006

A solution to an problem of Hibernate: "Servlet action is not available"

if in the xx.hbm.xml file, you made a mistake,like: you write a wrong property name which doesn't exist in the mapping class. say: "username" is a property in the class "User.class",but you write it as "usename". Then the problem happens, "Servlet action is not available" will display on your page.

Sunday, May 28, 2006

The configuration of Web.xml of struts

There are two parameters in the web.xml, like: "debug" and "detail", code is as follows:



Are these two parameters only work in the struts 1.1?
Here is one link about this:

Saturday, May 27, 2006

Different versions of Hibernate

Hibernate has version 2 and version 3. There are some differences between them, so We must pay attention to these differencs when we are programming.

Tuesday, April 25, 2006

The solutions to the problem:ClassNotFoundException: org.hibernate.hql.ast.HqlToken

When I run the example provided by the Hibernate 3.1.3 package, "ant eg", I got the error: "ClassNotFoundException: org.hibernate.hql.ast.HqlToken.
The solutions have two which I tried and succeeded.
1: place the antlr-2.7.6rc1.jar into the directory of jdk package.
2: set the "hibernate.query.factory_class" to "org.hibernate.hql.classic.ClassicQueryTranslatorFactory" in the "" file.
3: Or add the following sentence into the hibernate.cfg.xml file: org.hibernate.hql.classic.ClassicQueryTranslatorFactory

Monday, April 24, 2006

To run Hibernate example, We must put log4jXXX.jar into the "ext" directory of JDK

To run Hibernate example successfully, We must place log4jXXX.jar into the "jre/ext" directory of JDK (like: JDK1.5.0_06). for example, we can run the example provided by Hibernate package: "ant eg".
otherwise, it will have an error:
java.lang.ExceptionInInitializerError at......
Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: No suitable Log constructor

Sunday, April 16, 2006


1:copy "struts.jar" and "servlet-api.jar" to the directory, something like: E:\jdk1.5.0_06\jre\lib\ext. 注意拷到 jre 之下, 其中 servlet-api.jar 是由应用服务器,如tomcat提供的。这样用javac在编译beans才能通过

Tuesday, April 04, 2006

使用html:link tag 传递带空格的参数所产生的问题

我有上面的语句,其中dishNameForUrl的值带有空格,如:chicken curry .
这时产生的url为: "xxxx/" . 其中空格自动转换成了“+“符号。如果想保留空格,或者成为"xxxx/" 请问该如何处理? 我知道用“a href...<%=... %> />“或许能解决这个问题. 但如果只用 html link tag能解决这个问题吗?