开发者

Eclipse: formatting JavaScript Snippet embedded in JSP

Pressing Ctrl+Shift+F on a JSP editor in eclipse only formats the codes within html tags and jsp tags.

But my JSP file has a lots of JavaScript( unformatted) embedded using <script> </script>. So it very difficult to read the JavaScript code.

My Question is:

Is there any plugin or any other way to format those embedded JavaScript along with the HTML/JSP codes to make them readable?

If anyone has alre开发者_开发技巧ady figured out a way to do this, please let me know.


Well, it seems there is no such way to Format the javascript code mixed into jsp.

Anyway, you can use following simple trick.

  • extract the javascript code into a .js file, format it there and copy the formatted code back to main file.


First, affirming the important point provided by kirilloid above: avoid JS in HTML/JSP files.

Second, look at the SO discussion Is there a good JSP editor for Eclipse? for further information. Short answer: the Eclipse Web Tools Project (WTP) will format JavaScript in your JSPs.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜