曾经颇困扰我的一个路径问题。。

JSTL有解决了,struts的html:image和html:link也可以部分解决

我发现我总是倾向于去找现成的东西,而lihe君则总是倾向于自己写。。

The <c:url> also performs another nice service. As you may be aware, relative URLs in HTML elements must either be relative to the page that contains them or to the root directory of the server (if they start with a slash). The first part of a URL path for a JSP page is called the context path, and it may vary from installation to installation. You should therefore avoid hard-coding the context path in the JSP pages. But sometimes you really want to use a server-relative URL path in HTML elements; for instance when you need to refer to an image file that’s located in an /images directory shared by all JSP pages, no matter where in the document structure the page reside. The good news is that if you specify a URL starting with a slash as the <c:url> value, it converts it to a server-relative path. For instance, in an application with the context path /myApp, the <c:url> action converts the path to /myApp/images/logo.gif:

<c:url value="/images/logo.gif" />
There are a few more actions related to URLs in the Core library. The <c:import> action is a more flexible action than the standard <jsp:include> action. You can use it to include content from resources within the same Web application, from another Web application in the same container, or from another server, using protocols like HTTP and FTP. The <c:redirect> action lets you redirect to another resource in the same Web application, in another Web application, or on a different server. Both actions are straightforward to use, so I leave it as an exercise for you to try them out.

from tomcat to resin,一点体会

下午折腾了很久的服务器配置,写点备忘

起因是信息网那套tag里面的boardList在tomcat下没法用,因为有个pClassCode这样的属性,tomcat里面会报错Unable
to find setter method。google一番查到一个解释如下:
Q. I have a bean with a property whose second letter is capitalized.

Why won ‘t my JSP page that uses this bean compile?

A. This may not happen often, but can be difficult to determine why.

The reason is found in the Java Beans specification, where in section

"8.8 Capitalization of inferred names " it states:

Thus when we extract a property or event name from the middle of an

existing Java name, we normally convert the first character to lower

case. However to support the occasional use of all upper-case names,

we check if the first two characters of the name are both upper case

and if so leave it alone.

This means that if you have a bean with a setter method of "setXLoc ",

then the inferred property is "XLoc ", not "xLoc ". If you used this

bean in a JSP page and you tried to use "xLoc " as the property, it

would not compile. Using "XLoc " as the property would succeed.

If you insist on using "xLoc " on the JSP page, you can make this
possible

by creating a BeanInfo class for the bean. The following is an example

of such a BeanInfo class for a simple bean called Coordinate. It

explicitly defines the properties of the bean to be "xLoc " and "yLoc
".

import java.beans.*;

public class CoordinateBeanInfo extends SimpleBeanInfo

{

private final static Class beanClass = Coordinate.class;

public PropertyDescriptor[] getPropertyDescriptors()

{

try {

PropertyDescriptor xLocDesc new PropertyDescriptor( "xLoc ",beanClass,
"getXLoc ", "setXLoc ");

PropertyDescriptor yLocDesc new PropertyDescriptor( "yLoc ",beanClass,
"getYLoc ", "setYLoc ");

PropertyDescriptor [] pdv = { xLocDesc, yLocDesc };

return pdv;

} catch (IntrospectionException e) {

throw new Error(e.toString());

}

}

}

尝试这里面提到的这个附加类的方法,不知所云。没有tag的源码,不能改属性名。无奈之下改用resin。
一直不用resin的原因主要是intellij默认整合了tomcat,调试起来比较爽。以前找到过一个resinplugin,但是只能用在
intellij4.0上(我现在用的是4.5)。开始google,惊奇的发现那个resinplugin的project已经发布2.9.2版了(我
上次用的还是1.0.2版-_-),下载,不大知道怎么用。翻看intellij的官方Forum,发现一个很奇怪的方法可以work:)
很好很好。大概的思路就是把resin的Jar导入,然后当作一个Application来运行ResinServer类的main方法。写好conf和
各种参数就ok了。原文如下:

I just
set it up as a regular application, like this:

Main class: com.caucho.server.http.ResinServer

VM parameters:
-Dcom.sun.management.jmxremote
-Dresin.home=.
-Dlog4j.configuration=c:/dev/projects/template/webapp/conf/log4j.properties
-Xdebug -Xnoagent -Djava.compiler=NONE
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=12345
-Dfile.encoding=UTF-8 -XX:PermSize=64M -XX:MaxPermSize=64M

Program parameters:
-conf resin.xml

Working directory:
C:\dev\projects\template\webapp

Use classpath and JDK of module:
webapp

Then I can "run" it or "debug" it with no problem and it logs directly
to the console in IDEA.


可怜plugin的那个作者在下面无奈的说”I know that the need for a
plugin is not that big…“,哈哈

然后又遇到过一个问题,就是resin说什么找不到jstl的类。。折腾了半天,把代码里的jstl都去掉,remove掉intellij里面的各个地
方加上的jstl的类库,remove掉docbase里面的jstl库,ok了。resin2.x版本都不支持jstl的tld的xml
schema。。所以没法在resin2.x里面用jstl。配一个resin3又太麻烦了。(我现在还没空学这个)

resin爽的地方有两个,一个是特别快,启动和编译页面的速度都好过tomcat不少;二是没有tomcat那个莫名其妙的server
path和context
path混淆的问题,tomcat里面写/开头的路径都会解释成server-dependent的(好像应该叫server-side?),弱智的
bug。。。

嗯,记录完毕

几个经验。。

 Intellij4.5下面配置tomcat,发现没法改动server.xml。Intellij总是在自己的临时目录底下开一个目录,建一套conf,我设置了tomcat base也不起作用。一怒之下看到它还是从catalina的一个startup.bat之类的bat文件开始启动tomcat的,就直接去改了那个bat,把calatina_base环境变量强制置成tomcat的安装目录(不读启动参数了),于是搞定。。

JSP开发中遇到了中文问题。。解决方法如下,所有页面设置成GB2312,每个页面读request参数之前request.setCharacterEncoding("GB2312"),注意一定要在开始读参数之前设置。。刚遇上这个问题的时候就是在读取参数之后才设置编码,结果不行,提交中文信息的表单一律用POST方法(这个倒是我试出来的,估计要用GET方法的话要对url做一下encoding)。ok

 <jsp:include…

 <jsp:include page="<%=request.getParameter("xxx")%>" />

这个用法是不对的。。可能是因为include是在jsp转servlet之前进行。。混乱的知识结构,唉

Published
Categorized as Uncategorized Tagged , ,

 Lomboz配置 …

 Lomboz配置

配了一个多钟头的Lomboz了。。Eclipse死硬派,呵呵,主要依据官方Tutorial
 
真是麻烦。。
Tomcat5.0.30还跑不起来,在 http://dev.csdn.net/article/42/42567.shtm 这个blog的文章里看到解释(CSDN居然丢图片。。还是去搜了一把才在别的地方看到这个文章的图片)
现在有价值的文章在blog上出现的概率越来越大了,呵呵

好像要改的地方还好多。。先出去玩了,呵呵,司马台