How to integrate Eclipse Dynamic Web Project Folder structure with Tomcat6
I want to create a web project in Eclipse, but I don't understand the Folder Structure of the project. It is different with the "webapps" folder layout which state in Tomcat6 Folder. Could anyone tell me which folder I should put web file(like: html, jsp), which folder I should put java source, which folder I should put the servlet file.
Here is the Project in Eclipse:
Web Project - build - Webcontent * META-INF * WEB-INF * - scr (not default one) * - classes(not default one) * - web.xml - JavaSource * scr
now what I 开发者_如何学Godid is put .java file into /JavaSource/src , and put .jsp file into /WebProject/WEB-INF, and when I import such as "test.java" into "index.jsp" I write following:
<%page import="test.java" %>
but it shows error in eclipse. what is the correct way of organize those files to create a meaningful standard project.
- You should put *.jsp files under WebProject/WebContent
- You should put *.java source files under WebProject/JavaSource/src/your/package/name
- To reference a java class from JSP you need to use its fully qualified name e.g.
<%page import="your.package.name.Test" %>
, where Test is the name of the class located in Test.java in WebProject/JavaSource/src/your/package/name
精彩评论