JSP标签可以在JavaScript中使用吗?
我正在 JavaScript 中构建一些 HTML 以传递回 JSP,我正在这样做:
var html = "<td id='comment-" + comment.id + "'class='wrappable' style='width:400px;'>"
+ "<pre style='width: auto;'>" + comment.comment + "</pre></td>";
但是我发现了一些 JSP 标记可以用作使用
的替代方案来解决我的 newLine 问题:
var html = "<td id='comment-" + comment.id + "'class='wrappable' style='width:400px;'>"
+ "<ctl:breakNewline target='" + comment.comment + "'/></td>";
但好像没用。这是如何引起的以及如何正确解决?
I'm building some HTML in JavaScript to be passed back to a JSP and I was doing this:
var html = "<td id='comment-" + comment.id + "'class='wrappable' style='width:400px;'>"
+ "<pre style='width: auto;'>" + comment.comment + "</pre></td>";
But I found some JSP tag to use as an alternative to using <pre>
to solve my newLine problem:
var html = "<td id='comment-" + comment.id + "'class='wrappable' style='width:400px;'>"
+ "<ctl:breakNewline target='" + comment.comment + "'/></td>";
But it doesn't seem to work. How is this caused and how can I solve this properly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在没有使用过 JSP 或 JSTL 的情况下,我会对此进行大胆猜测并说:不。
据我所知,JSP 仅是服务器端的,除非您在服务器上运行此 html 生成代码(而不是在浏览器/客户端),在将其传递给 JSP 解析器之前在服务器上使用一些 javascript 解析器,这是行不通的。
Without ever having used JSP or JSTL I'm going to take a wild guess at this and say: No.
As far as i know, JSP is server-side only, and unless you're running this html generating code on the server (rather than in browser/client-side), with some javascript parser on the server before passing it to the JSP parser, this will not work.
JSP 在服务器上计算,JavaScript 在客户端上计算。不,这行不通。
(当然,您可以使用 JSTL 创建整个 JavaScript 代码,但不能从 javaScript 调用 JSP 代码)
JSP is evaluates on the server, JavaScript on the client. No, this can't work.
(Of course you can use JSTL to create your entire JavaScript code, but you can't call JSP code from javaScript)