How to share web content between eclipse projects

前端 未结 4 904
青春惊慌失措
青春惊慌失措 2021-02-07 04:28

While the J2EE module reference feature allows your to create common Java library projects, I can\'t find a neat way to do this for web content.

I have common JSPs, CSS

相关标签:
4条回答
  • 2021-02-07 04:46

    haha,i give u a late surprise

    i'm Chinese,my english is poor, but i can help u .

    Olaf Kock is right ,but his answer not perfect.

    Here is the perfect answer. u have to refer the follow url, it can hep u.

    click here

    in the url page, the example for the property content box is not exact, u fllow me:

    if need to share a file:

    a.jsp  svn://myhome.com/svn/myproject/trunk/a.jsp
    

    if need to share a folder:

    xml  svn://myhome.com/svn/myproject/trunk/xml
    
    0 讨论(0)
  • 2021-02-07 04:47

    I've been wrestling with the same problem for a long time, and finally stumbled onto a good solution: "Linked Folders". This is an Eclipse feature that works similarly to symlinks -- it allows you to map a single physical folder into multiple projects. The nice thing about this solution is that it doesn't require any special build steps, so Eclipse can automatically deploy changes to your local Tomcat server for testing.

    My configuration is as follows: I have an Eclipse project named "SharedContent". Inside the WebContent directory, is a subdirectory "shareRoot". All reusable files -- .jsp, .css, etc. -- are located somewhere under SharedContent/WebContent/shareRoot. This is a Dynamic Web Project so that all of the appropriate editors are enabled, but I never actually build or deploy it.

    In my other projects, I add a Linked Folder pointing to shareRoot. In Eclipse 3.6, the steps are:

    1. In the Package Explorer, right-click on the WebContent directory of the project that needs to include the reusable files.

    2. Select New -> Folder.

    3. Click the "Advanced>>>" button.

    4. Select the "Link to alternate location (Linked Folder)" radio button.

    5. In the textbox just under this, click Browse.

    6. In your source tree, navigate to SharedContent/WebContent/shareRoot. Then click OK/Open/Finish buttons until all the dialogs go away.

    The shared content is now mapped into your project. Annoyingly, you have to include "shareRoot/" in the URL when referencing these files, but you can work around this using your favorite URL rewriting filter.

    You can use a similar trick in the Java source tree to map Java files into multiple projects. I've started doing that, instead of building the shared code into a .jar file, because it avoids the need to rebuild the .jar every time you want to test a change in your local Tomcat server.

    0 讨论(0)
  • 2021-02-07 04:50

    If you're using Subversion, you could use svn:externals to reference the common files in both projects. Then you can edit the common files in one place, and if you do a svn up all will be synchronized.

    0 讨论(0)
  • 2021-02-07 04:56

    I believe writing your own scripts (e.g. custom build steps using ant, easily configurable in eclipse) is among the more practical solutions.

    You could also create multiple webapps and reference their respective resources - this would be easy with css, images and the like, not so much with jsp that need to access your code being available.

    I can imagine some tricks with tomcats crossContext="true" option for the context (e.g. webapplication), enabling one application to access classes in an other application, but haven't tried them yet.

    Sorry - I believe that's not the answer you'd like to hear...

    0 讨论(0)
提交回复
热议问题