struts2和FCKEditor struts2 怎样获得FCKEditor的内容啊?比如要是普通的表单,在Action中定义一个属性和表单的name一样就行了,但是FCKEditor就不行啊! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 看看我的blog就知道了http://blog.csdn.net/lihan6415151528/archive/2008/10/18/3094793.aspx 同样的在Action中定义一个属性和表单的name一样就行了然后导入fckeditor.js在页面上添加JS:<textarea id="content" name="content" style="WIDTH: 100%; HEIGHT: 400px">input</textarea><script type="text/javascript"> var oFCKeditor = new FCKeditor('content') ; //content为你在action中定义的属性 oFCKeditor.Height = 400; //高宽自己定义 但不会超过css的样式 oFCKeditor.ToolbarSet = "Default" ; //FCK中的选项样式 这里使用默认 可参考源码里的定义自己修改 oFCKeditor.ReplaceTextarea();</script>这就是最简单的使用 FCKEditor在提交时就是一个普通的http post提交,只要在Struts 2的Action类或模型类中加入与FCKEditor编辑器名相同的属性即可。属性类型是String类型。var oFCKeditor = new FCKeditor('content') ;属性名就是FCKEditor框架方法的参数值。 请看下面的HTML的代码,基本上你按照下面的配置就可以在Struts使用Fck了。其实Fck和Struts是没有什么关联的。1. fck放在WebRoot下面,使得你的Web应用程序能访问得到2. 加入一个textarea,3. 使用onload事件把textarea替换成fckeditor4. submit的时候你在后台代码中要定义一个get方法和textarea中的name要匹配 如:<textarea rows="5" cols="35" name="description"></textarea> 的name是description 那必须要有个getDescription()的方法。<!--fck这个文件夹要放在WebRoot目录下面--><script type="text/javascript" src="fck/fckeditor.js"></script><!--Struts的表单--><s:form action="myAction" name="myForm"> <textarea rows="5" cols="35" name="description"></textarea> <input type="submit" value="提交" /></s:form><script type="text/javascript">//初始化的一个onload事件,用于把名字为description的textarea html标签替换成FCK的Editorfunction init() { var bodyFCKeditor = new FCKeditor('description'); bodyFCKeditor.BasePath = 'fck/'; bodyFCKeditor.ToolbarSet = 'Default'; bodyFCKeditor.Width = '95%'; bodyFCKeditor.Height = '400'; bodyFCKeditor.Value = ''; bodyFCKeditor.ReplaceTextarea(); }//onload事件window.onload = init;</script> jsp中file,怎么能够在action中找到 Eclipse无法启动 web.xml引入其他的xml出现错误,求助~ hibernate 的查询语句怎么写 很简单的 :) 如何使用jms作为通讯机制实现glassfish集群 如何NetBeans 开发EJB 我的jbuilder光标有问题,有谁遇到过类似的情况,该怎么解决 EJB,CORBA的问题!问题多多!在线等待! 为什么我的JBuilder5用不了EJB? 子集和如何凑整? Struts中update一条记录后返回记录页面原纪录没有改变,该怎么办? 实现查询
http://blog.csdn.net/lihan6415151528/archive/2008/10/18/3094793.aspx
然后导入fckeditor.js
在页面上添加JS:
<textarea id="content" name="content" style="WIDTH: 100%; HEIGHT: 400px">input</textarea>
<script type="text/javascript">
var oFCKeditor = new FCKeditor('content') ; //content为你在action中定义的属性
oFCKeditor.Height = 400; //高宽自己定义 但不会超过css的样式
oFCKeditor.ToolbarSet = "Default" ; //FCK中的选项样式 这里使用默认 可参考源码里的定义自己修改
oFCKeditor.ReplaceTextarea();
</script>这就是最简单的使用
1. fck放在WebRoot下面,使得你的Web应用程序能访问得到
2. 加入一个textarea,
3. 使用onload事件把textarea替换成fckeditor
4. submit的时候你在后台代码中要定义一个get方法和textarea中的name要匹配
如:<textarea rows="5" cols="35" name="description"></textarea> 的name是description
那必须要有个getDescription()的方法。
<!--fck这个文件夹要放在WebRoot目录下面-->
<script type="text/javascript" src="fck/fckeditor.js"></script>
<!--Struts的表单-->
<s:form action="myAction" name="myForm">
<textarea rows="5" cols="35" name="description"></textarea>
<input type="submit" value="提交" />
</s:form>
<script type="text/javascript">
//初始化的一个onload事件,用于把名字为description的textarea html标签替换成FCK的Editor
function init() {
var bodyFCKeditor = new FCKeditor('description');
bodyFCKeditor.BasePath = 'fck/';
bodyFCKeditor.ToolbarSet = 'Default';
bodyFCKeditor.Width = '95%';
bodyFCKeditor.Height = '400';
bodyFCKeditor.Value = '';
bodyFCKeditor.ReplaceTextarea();
}//onload事件
window.onload = init;
</script>