1

我正在使用 textarea 进行用户文本输入,但为了保留文本格式,我决定尝试 tinyMCE。

我需要做什么:

  1. 通过将内容发布到 servlet,将输入到 tinyMCE 编辑器中的输入保存到数据库中。
  2. 从服务器检索保存的文本并将其显示在 tinyMCE 中以进行任何编辑。

问题描述:这是我从服务器检索到的文本发送到前端 JSP 的方式:

request.setAttribute('inputText',txt);
RequestDispatcher view = request.getRequestDispatcher("/TextareaTest.jsp");
view.forward(request, response);

在 JSP 页面中,我只使用 JSTL/EL。因此,要访问请求对象中的值,我使用 ${requestScope['inputText']} 或 ${inputText}

例子:

<script type="text/javascript">
var txt = "${requestScope['inputText']}";
tinyMCE.get('textarea1').setContent(txt);
</script>

但这不适用于 tinyMCE。不知何故,我无法像在集成 tinyMCE 之前那样访问请求对象。如果我删除 tinyMCE,它工作正常。但现在它就像一个普通的文本区域。

需要弄清楚如何通过 javascript 函数内部的 servlet 访问请求对象上设置的值。

谢谢

4

1 回答 1

0

I got it to work. I was trying to call the save() on the editor instance which seemed to be causing the problem. I removed that and am able to access the sessionScope

于 2013-01-25T11:46:09.583 回答