以前的fckeditor在jsp中使用时,可以把编辑器的默认值写在标签体中,如下
<FCK:editor id="documentContent" >
<a href="padp.jsp">Plug-in Application Develop Platform</a>
</FCK:editor>
但在使用fckeditor2.6.4和for java 2.4时不能用上面那种方式写只能这样写
<FCK:editor instanceName="content" value="PADP"> </FCK:editor>
这样的缺点就是不能把默认值设置为带"或'的内容
不知道fckeditor为什么后来的版本不支持了,没办法,只改给改了
1.把fckeditor-java-2.4.1-src中java源文件copy到工程中(记得把原来fckeditor-java-core-2.4.1.jar中的net.fckeditor.handlers下的default.properties复制到工程中对应包,还有把FCKeditor.tld复制到Web-Inf下)
2.修改net.fckeditor.FCKeditor.EditorTag文件
把extends TagSupport改为BodyTagSupport
删除原来的doStartTag(),doEndTag()方法,然后添加以下两个方法:
public int doStartTag() throws JspException {
return EVAL_BODY_BUFFERED;
}
public int doAfterBody() throws JspException {
BodyContent body = getBodyContent();
String bodyString="";
if (body!=null) {
bodyString = body.getString();
}
try {
if (bodyString.trim().length()>0) {
value=bodyString;
}
JspWriter writer = body.getEnclosingWriter();
fckEditor = new FCKeditor((HttpServletRequest) pageContext
.getRequest(), instanceName, width, height, toolbarSet,
value, basePath);
writer.println(fckEditor);
} catch (Exception e) {
throw new JspException(e);
}
return SKIP_BODY;
}
3.这样再用下面的方式写就没问题了
<FCK:editor id="documentContent" >
<a href="padp.jsp">Plug-in Application Develop Platform</a>
</FCK:editor>
有问题?直接google! <script type="text/javascript"> </script> <script src="http://pagead2.googlesyndication.com/pagead/show_sdo.js" type="text/javascript"></script>
<script type="text/javascript"> </script> <script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script>