Eclipse run jsp files or web project

Premise: Eclipse (Chinese version) running, java environment (jdk1.8 version) set up is completed

1. On your computer download (deployment) good Tomcat

PS: tomcat java ee is in line with the minimum standards of the web server, it can be done most of the development of small-scale systems, and provides support, is the largest watershed tomcat after tomcat4.1, and after some changes have taken place tomcat5.5 , to use today tomcat9.

① official website  http://tomcat.apache.org/  download Tomcat installer on (here I chose exe program to install Tomcat)

         

 

PS: In order to avoid Tomcat 9 will conflict with some operations on Eclipse, I chose to download Tomcat 8.5 version

② run apache-tomcat-8.5.50.exe program, not much to say here, to finally finish.

To prove Tomcat installation is successful, we need to start to look at Tomcat open the page  http: // localhost: 8080 / Is there Apache Tomcat page

You can refer to ③ below how to start step Tomcat

③ When I above steps for installing Tomcat is installed in the directory E: \ Program \ Tomcat-8.5, the next,

①win + R, input cmd, Enter

② Input e:, Enter

③ Input cd E: \ Program \ Tomcat-8.5 \ bin, Enter

④ input startup.bat, carriage return

⑤ browser to open http: // localhost: 8080 /, Apache Tomcat page will be successful.

 

2. Tomcat + Eclipse

(1) carried out a series of operations in the Eclipse Help:

① Click Help -> Install New Software (Help -> Install New Software)

② in Work with: Enter or select a site, a space line input

Oxygen - http://download.eclipse.org/releases/oxygen

③ the last line of the following options: Web, XML, Java EE and OSGi ..... expand out

④ Check 5:

    clipse Java EE Developer Tools
    Eclipse Java Web Developer Tools
    Eclipse Web Developer Tools
    Eclipse XML Editors and Tools

    JST-Server Adapters Extensions

⑤ Next, Next, choose to accept, is completed. Then wait for the progress bar at the bottom of the Eclipse, Eclipse restart after the end of the line.

(2) a series of operations performed in the Eclipse Wndow:

Open Window - Preferences (Windows -> Preferences)

(3) create a web project execution jsp files in Eclipse

① Click File-> New-> Dynamic Web Project.

PS: If the Dynamic Web Project option does not appear in the File-> New, then choose Other, enter the Web, should appear Dynamic Web Project

② named in the Project name, I named Demo

③ Click New runtime in the target runtime, choose to install their own version of tomcat

④ In the Dynamic webmodule version, select 3.1

⑤ in Cononfiguration click Modify, check follows FIG determined

 ⑥ Click finish, and then the results shown below

 ⑦ Next, create a simple jsp page, the figure above the red arrow in the file folder, right-click, click new-> jsp file, fill in the file name in the file name, I wrote 01, then click finish, the following results

 ⑧ Click 01.jsp, enter the following code, save

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
123
</body>
</html>

⑨鼠标右键,Run As -> Run on Server(运行方式-> Run on Server),弹出Run on Server对话框,按照下面两个图操作完finish

PS:如果是第一次运行web项目,先创建个服务器,如下图

 

 finish后出现下图

(4)导入(加载)其他Web项目

同样像上面一样需要先创建一个web项目

右键点击web项目,点击import ->import

选择File Systms(文件系统),点击next

点击Browse(浏览),加载目标web项目的路径,点击finish

PS: 如果不先创建一个新的空的web项目,而直接在File选项下导入文件夹,可能会有一些错误需要处理,所以并不建议这么做

PS: 导入web项目后要注意我们是希望运行文件是在WebContent目录下的,如果不是在这个目录下,可以在文件目录下自己操作一番,再回到Eclipse下该项目右键刷新

PS: 如果在点击时Run As -> Run on Server 没有 Run on Server选项的话,可以参考下如下做法:

①打开该web项目的.project文件

②添加如下代码

在 <natures> </natures>中加入

<natures>
        <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
        <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
        <nature>org.eclipse.jdt.core.javanature</nature>
        <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
        <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
</natures>

在 <buildSpec> </buildSpec>中加入

<buildSpec>
        <buildCommand>
            <name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
            <arguments>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>org.eclipse.wst.common.project.facet.core.builder</name>
            <arguments>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>org.eclipse.jdt.core.javabuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>org.eclipse.wst.validation.validationbuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
 </buildSpec>

③回到Eclipse,右键刷新web项目,Run on server 应该能有了。不过,如果没有按照前面的步骤先把一些该加载的该勾选的内容弄完,那么这里可能还需要再多做些别的操作。

PS: 如果出现因为端口问题导致服务器打不开的话,可以参考如下做法

Guess you like

Origin www.cnblogs.com/pskcoco/p/12047065.html