Eclipse Web Tools Project是否处理JSP内部的重构? [英] Does the Eclipse Web Tools Project handle refactoring inside JSPs?

查看:123
本文介绍了Eclipse Web Tools Project是否处理JSP内部的重构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为Eclipse 3.4版安装了Web Tools Project。我一直在尝试以我认为的方式进行重构,并且没有成功。

I've installed the Web Tools Project for Eclipse version 3.4. I've been trying to get refactoring working the way I think it should and have had no success.

我有一个包含jar的Java类的Java项目被放入/ WEB-INF / lib的网站。另一个项目(动态Web项目)具有同一站点的JSP文件。动态Web项目使用Java项目作为构建路径中的必需项目进行设置。我还为Dynamic Web项目设置了Project References选项以引用Java Project。

I have one Java project that contains the Java classes for the jar that is put into the /WEB-INF/lib for a web site. Another project (a Dynamic Web project) has the JSP files for the same site. The Dynamic Web project is set up with the Java project as a required project in the build path. I have also set the Project References option for the Dynamic Web project to refer to the Java Project.

如果我使用重构来更改其中一个Java类中的方法名称,我希望重命名JSP中对该方法的引用。但它不起作用。 Java项目中包含类和其他使用该类的Java项目的引用已更改引用,但不是对JSP内部方法的引用。

If I use refactoring to change a method name in one of the Java classes, I would expect that references to that method in the JSPs would be renamed. But it does not work. References in the Java project that contains the class and other Java projects that use that class have the references changed are refactored, but not references to the method inside the JSPs.

I几天来一直在摆弄它,尝试不同版本的Eclipse和WTP。删除我的所有项目和文件并重新设置它们。没有什么区别。

I've been fiddling with it for days, trying different versions of Eclipse and WTP. Deleting all my projects and files and setting them up again. Nothing makes any difference.

这对其他人有用吗?有什么特别的东西我需要设置才能让它工作吗?

Does this work for anyone else? Is there something special I need to set to get this working?

推荐答案

对不起,这不是直接回答你的问题,但仍解决你的问题...也许有帮助,否则请忽略:

Sorry, this is not directly answering your question but nevertheless addressing your problem... maybe it helps, otherwise please ignore:

正如matt b建议的那样,你不应该把java代码放在jsp中。而是简单地使用标签。如果您正在使用标准标签库,那么几乎所有您需要的东西。对于你必须自己处理的事情,一旦你知道了什么标签,编写自己的标签就非常简单了。

As matt b suggested, you should not place java code in a jsp. Instead 'simply' use Tags. If you're using the standard tag library, there's almost everything there that you need. For things that you must handle yourself, it's very simple to write your own tags once you know what tags are about.

通过这个技巧,您将获得更好的应用程序(视图)架构,测试机会(希望您喜欢它们),坚持DRY(不要重复自己)原则并将所有Java代码放在.java文件中,以便任何工具轻松获取它们。

With this trick you'll get a better application (view) architecture, opportunity for tests (hope you like them), adhere to the DRY (dont repeat yourself) principle and place all Java code in .java files, so that they will easily be picked up by any tool.

甚至还有一个Web选项.xml强制禁用脚本,让标签工作,但如果你已经对脚本jsps进行了大量投资,这可能不是你需要的......

There's even an option for web.xml to enforce disabling scripting, leaving tags working, but if you already have a huge investment in scripted jsps, this might not be what you need...

<jsp-config>
  <jsp-property-group>
    <url-pattern>*.jsp</url-pattern>
    <scripting-invalid>true</scripting-invalid>
  </jsp-property-group>
</jsp-config>

您没有问过的问题的另一个答案是IntelliJ Idea处理您谈话的场景非常好(虽然我每天都在使用eclipse,这是两个IDE之间的差异之一)

Another answer to a question that you didn't ask is that IntelliJ Idea handles the scenario that you talk about very well (though I'm using eclipse myself day to day, this is one of the differences between both IDEs)

这篇关于Eclipse Web Tools Project是否处理JSP内部的重构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆