lilingjie2015 发表于 2015-8-10 08:52:20

fedora下eclipse安装tomcat插件

  首先下载tomcat插件: http://www.eclipsetotale.com/tomcatPlugin.html,下载最新的3.3版本;
  由于我的eclipse是通过yum自动安装的,因此eclipse在默认的路径下/usr/lib/eclipse/,将tomcat插件解压后,把com.sysdeo.eclipse.tomcat_3.3.0文件夹放在eclipse默认路径下的/plugins路径下;
  然后重启eclipse,即可看到有tomcat图标了。
  
  配置tomcat的文章,参考:http://blog.iyunv.com/njchenyi/article/details/6042760,虽然是windows的,但没有本质差别;
  创建servlet,参考:http://blog.iyunv.com/njchenyi/article/details/6042763;
  
  
  使用命令行,也可以编译servlet.
  首先,将编译用的api文件拷贝到java文件同一目录下,我用的是/usr/share/java/servlet_2_4_api.jar;
  然后使用javac -classpath servlet_2_4_api.jar HelloWorldExample11.java进行编译;即可生成class文件;
  HelloWorldExample11.java代码如下:
  
  import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
  /**
* The simplest possible servlet.
*
* @author James Duncan Davidson
*/
  public class HelloWorldExample11 extends HttpServlet {
  
    public void doGet(HttpServletRequest request,
                      HttpServletResponse response)
      throws IOException, ServletException
    {
      ResourceBundle rb =
            ResourceBundle.getBundle("LocalStrings",request.getLocale());
      response.setContentType("text/html");
      PrintWriter out = response.getWriter();
  out.println("");
      out.println("");
  String title = rb.getString("helloworld.title");
  out.println("" + title + "");
      out.println("");
      out.println("");
  // note that all links are created to be relative. this
// ensures that we can move the web application that this
// servlet belongs to to a different place in the url
// tree and not have any harmful side effects.
  // XXX
      // making these absolute till we work out the
      // addition of a PathInfo issue
  out.println("");
      out.println("");
      out.println("");
      out.println("");
      out.println("" + title + "");
      out.println("");
      out.println("");
    }
}
页: [1]
查看完整版本: fedora下eclipse安装tomcat插件