当前位置: 代码迷 >> Web前端 >> java工程转化作web工程
  详细解决方案

java工程转化作web工程

热度:180   发布时间:2012-12-23 11:28:15.0
java工程转化为web工程

??? Eclipse下新建java工程后,将工程手工改造为web工程:

?? ?修改工程目录下的.project文件
??? 普通工程下的该文件内容是:

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
 <name>xxx</name>
 <comment></comment>
 <projects>
 </projects>
 <buildSpec>
  <buildCommand>
   <name>org.eclipse.jdt.core.javabuilder</name>
   <arguments>
   </arguments>
  </buildCommand>
 </buildSpec>
 <natures>
  <nature>org.eclipse.jdt.core.javanature</nature>
 </natures>
</projectDescription>

?
替换成下面

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
 <name>Pro</name>
 <comment></comment>
 <projects>
 </projects>
 <buildSpec>
  <buildCommand>
   <name>com.genuitec.eclipse.j2eedt.core.WebClasspathBuilder</name>
   <arguments>
   </arguments>
  </buildCommand>
  <buildCommand>
   <name>org.eclipse.jdt.core.javabuilder</name>
   <arguments>
   </arguments>
  </buildCommand>
  <buildCommand>
   <name>com.genuitec.eclipse.j2eedt.core.J2EEProjectValidator</name>
   <arguments>
   </arguments>
  </buildCommand>
  <buildCommand>
   <name>com.genuitec.eclipse.j2eedt.core.DeploymentDescriptorValidator</name>
   <arguments>
   </arguments>
  </buildCommand>
  <buildCommand>
   <name>org.eclipse.wst.validation.validationbuilder</name>
   <arguments>
   </arguments>
  </buildCommand>
 </buildSpec>
 <natures>
  <nature>com.genuitec.eclipse.j2eedt.core.webnature</nature>
  <nature>org.eclipse.jdt.core.javanature</nature>
 </natures>
</projectDescription>

?
另外在.class文件中设置:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
 <classpathentry kind="src" path="src"/>
        ......
        <classpathentry kind="output" path="WebRoot/WEB-INF/classes"/>
</classpath>

?
src和output中的path选择你对应的java工程路径名