配置 Eclipse 以使用 Javascript 编辑器
在 Eclipse 中编辑 JSP 时, 标记的内容(即 Javascript 代码)会正确进行颜色编码和格式化。
由于超出了本问题范围的原因,我创建了一个自定义 JavaScript 标记,我们将其称为
。这种类型的主体是纯 JavaScript,就像在常规 标记中一样。
但是,当我的自定义标记中有 Javascript 代码时,它会被视为简单文本(没有颜色编码、没有正确的缩进等)。
我的问题是,如何使 Eclipse 在自定义 JSP 标记中使用特定编辑器?
When editing JSPs in Eclipse, the contents of <script>
tags - i.e. Javascript code - is properly color coded and formated.
For reasons that go beyond the scope of this question, I have created a custom javascript tag, let's call it <sj:script>
. The body of this type is pure javascript as you would have in a regular <script>
tag.
However, when I have Javascript code within my custom tag, it is treated as simple text (no color coding, no proper indentation, etc).
My question is, how do I make Eclipse use a specific editor within custom JSP tags?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您可以尝试 MyEclipse 或 Aptana Studio。他们为网络开发提供了更好的编辑器。
但更好的方法是将 JS 放入不同的文件中,并使用
引用该文件:
[编辑] Eclipse 是开源的。下载 WTP 项目的代码,查找文本编辑器部分并搜索“脚本”。在您找到的所有位置中,也添加“sj:script”。
You can try MyEclipse or Aptana Studio. They offer much better editors for web development.
But a much better approach is to put the JS into a different file and reference that with
<script src="...">
:[EDIT] Eclipse is open source. Download the code for the WTP project, look for the text editor parts and search for "script". In all places that you find, add "sj:script", too.
您是否在使用自定义标记的 jsp 中包含了标记库描述符文件?
Have you included the Tag Library Descriptor file in the jsp where you are using the custom tag?
我有一个 Eclipse 插件列表,可以让 Eclipse 编辑 JS 文件:
http://www.delicious .com/powtac/javascript+eclipse
只需浏览链接并查看如何安装它们的不同描述。
I have a list of plugins for eclipse which enable eclipse to edit JS files:
http://www.delicious.com/powtac/javascript+eclipse
Just go trough the links and see the different descriptions how to install them.
AFAIK,编辑器是根据文件扩展名选择的,并且没有机制可以根据文件内的特定内容对其进行自定义。
我看到 2 个选项
将您的 javascript 代码段放入外部文件中,在自定义脚本标记内使用 include 指令。
AFAIK, editors are chosen based on file extension, and there's no mechanism to customize this based on particular content inside the file.
I see 2 options
Put your javascript snippet in an external file, use the include directive inside your custom script tag.
Eclipse 有一个模板功能,您可以在其中添加特定标签,该标签可用于所有 JSP 页面。
确保您已安装 Eclipse WTP (Web Tools Platform)
1.打开 Preferences 窗口 [ Select Window >偏好]
2.从菜单中展开Web选项,您可以在其中看到[CSS文件、HTML文件等。
3.选择JSP文件
4.选择编辑器
5.选择模板
6.在相应的窗格中,单击新建,然后可以轻松完成其余操作。
Eclipse has a template feature where in you can add specific tag ,which can be made available for all JSP pages.
Ensure you have installed Eclipse WTP ( Web Tools Platform )
1.Open Preferences window [ Select Window > Preferences ]
2.Expand Web Option from the menu, upon which you can see [ CSS Files,HTML Files etc..
3.Select JSP Files
4.Select Editor
5.Select Templates
6.In the corresponding pane , click New and from there rest can be easily done.