How to Merge GWT (Google Web Toolkit) Project and Dynamic Web Project (i.e. Java Web App/Servlets) in Eclipse?
I currently have a primary Java Web App Project which houses some Servlets, JSPs and static HTML pages. Later on, I also created a second Eclipse Google Web Toolkit Project (GWT). Now, after finishing the GWT Project, I want to integrate or merge the GWT Project (while retaining its RPC capabilities with Servlets) with the Primary Java Web A开发者_如何学编程pp Project. In which directory do I need to copy-paste the files and folders from GWT Project to Java Web App Project? Keep in mind that I want to export the fully compiled JavaScript code rather than Java byte code.
You can put all the Java files from your GWT project exactly where they were in the GWT project. I think your gwt.xml file can stay the same also. In your web.xml file, you'll need to define the servlet(s) that you use in GWT, for example if gwt.xml has <servlet path="/MyService" class="com.catfish.server.MyServiceImpl"/>
then web.xml will need:
<servlet>
<servlet-name>MyService</servlet-name>
<servlet-class>com.catfish.server.MyServiceImpl</servlet-class>
</servlet>
and
<servlet-mapping>
<servlet-name>MyService</servlet-name>
<url-pattern>/module-path/MyService</url-pattern>
</servlet-mapping>
Then use an ant build script to compile the GWT into WebContent/module-path. You can still run your GWT project using the GWT standalone browser, but when you want to run everything together, you'll compile the GWT project and then run Tomcat or Jetty or whatever servlet engine you're using. And you'll need to put the path to your generated GWT JavaScript app in whatever JSP or static page uses it.
If you only want to move the compiled javascript code, put it under a public access directory: i.e.
web-root/www
精彩评论