java 代码格式化程序:清理格式糟糕的 jsp 代码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1235301/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Code Formatter: cleaning up horribly formatted jsp code
提问by user16208
So I am working on a jsp/servlet that came to me and I'm looking at the jsp file and it is just a jungle of jstl tags, java code and html thrown together. At first it looked like someone ran the standard eclipse formatter on it and had the page width set to 40 so alot of stuff is broken up, I tried to format it with a larger page width but that seemed to make it worse to the point of not being able to tell what is going on without formatting parts of it first.
所以我正在研究一个来找我的 jsp/servlet,我正在查看 jsp 文件,它只是一堆 jstl 标签、java 代码和 html 扔在一起。起初看起来有人在上面运行了标准的 Eclipse 格式化程序并将页面宽度设置为 40,所以很多东西都被分解了,我试图用更大的页面宽度来格式化它,但这似乎使它变得更糟如果不先格式化部分内容,就无法判断发生了什么。
Anyone have any luck with any jsp/code formatter?
有人对任何jsp/代码格式化程序有好运吗?
回答by ChssPly76
Are you using Eclipse WTPplugin? If not, take a look at it - it has quite a few ways to customize formatting of JSP.
你在使用Eclipse WTP插件吗?如果没有,看看它 - 它有很多方法可以自定义 JSP 的格式。
If you are, JSP formatting can be customized under Window -> Preferences; Web -> JSP Files -> Editor; note that there are two separate links there - for XML and HTML JSP.
如果是,可以在Window -> Preferences 下自定义JSP 格式;Web -> JSP 文件 -> 编辑器;请注意,那里有两个单独的链接 - XML 和 HTML JSP。
回答by Dennis
I know that this question is for JSP, and not javascript, but this works pretty well all the same: http://jsbeautifier.org/
我知道这个问题是针对 JSP 的,而不是针对 javascript 的,但这同样适用:http: //jsbeautifier.org/
回答by Kevin Crowell
Netbeans does a decentjob at formatting my jsp code. You could download Netbeans 6.5.1 and format the files in there.
Netbeans在格式化我的 jsp 代码方面做得不错。您可以下载 Netbeans 6.5.1 并在其中格式化文件。
回答by Ray
Try maybe IntelliJ IDEA. I can't guarantee it will do the job better but it won't hurt to try.
试试也许 IntelliJ IDEA。我不能保证它会做得更好,但尝试不会有什么坏处。
回答by Antimo
This seems to work fine for mine JSP and JS code (free at the momenti'm using it)
这似乎适用于我的 JSP 和 JS 代码(在我使用时免费)
回答by Plasebo
Use this to format any HTML,JSP or any other language tag: https://www.freeformatter.com/html-formatter.htm
使用它来格式化任何 HTML、JSP 或任何其他语言标签:https: //www.freeformatter.com/html-formatter.htm

