1. 程式人生 > >ant下部署struts2開發環境

ant下部署struts2開發環境

1.安裝部署jdk,安裝部署tomcat伺服器,下載安裝ant構建工具,下載struts2的jar檔案

2.在電腦上新建一個資料夾test,在test資料夾下新建目錄lib、src、WEB-INF,在test資料夾下新建檔案index.jsp(見附1)

3.所有網站都要有web.xml檔案。從tomcat的webapps/在WEB-INF/ROOT/WEB-INF下,複製web.xml到test/WEB-INF/web.xml,修改其中內容(見附2),加入struts過濾器,使得所有地址都有struts代理執行

3.在struts2的jar中找個strtus.xml檔案,複製到test/src下(經過ant編譯後會複製到test/WEB-INF/classes目錄系,可手動建在此目錄),並修改其中內容(見附3)

4.index.jsp的表單提交後會提交acton到login中,web.xml中配置的struts過濾器會攔截請求,獲取請求引數後,在struts.xml中查詢匹配name=login的action,匹配成功會呼叫action處理類com.ltl.service.LoginAction,我們在test/src目錄下新建com\ltl\service目錄,並在本目錄下新建LoginAction類(見附4)

5.根據請求結果回返回“success”或“error”字串,返回struts.xml檢視,會跳轉到test/error.jsp(見附5)或test/welecom.jsp(見附6)頁面

6.在test檔案下新建ant構建檔案build.xml(見附7),將test資料夾複製到tomcat/webapps目錄下

7.在DOS下,輸入cmd,當前路徑到test目錄下,輸入命令ant,將看到test/src的內容編譯到test/Web-INF/classes下,test/lib資料夾複製到test/Web-INF下

8.在tomcat的bin目錄下,點選startup.bat,伺服器啟動。

附1:index.jsp

左尖括號%@ page contentType="text/html; charset=UTF-8" %右尖括號左尖括號%@ taglib uri="/struts-tags" prefix="s" %右尖括號左尖括號!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

""右尖括號左尖括號html xmlns="" xml:lang="en" lang="en"右尖括號左尖括號head右尖括號左尖括號title右尖括號使用者登入左尖括號/title右尖括號左尖括號/head右尖括號

左尖括號body右尖括號

左尖括號form action="login" method="post"右尖括號左尖括號table右尖括號左尖括號caption右尖括號左尖括號h3右尖括號使用者登入左尖括號/h3右尖括號左尖括號/caption右尖括號左尖括號tr右尖括號左尖括號td右尖括號使用者名稱: 左尖括號input type='text' name="username" /右尖括號左尖括號/td右尖括號左尖括號/tr右尖括號左尖括號tr右尖括號左尖括號td右尖括號密    碼: 左尖括號input type='text' name="password" /右尖括號左尖括號/td右尖括號左尖括號/tr右尖括號左尖括號tr align="center"右尖括號左尖括號td colspan="2"右尖括號左尖括號input type="submit" value="登入" /右尖括號左尖括號input type="reset" value="重填" /右尖括號左尖括號/td右尖括號左尖括號/tr右尖括號左尖括號/table右尖括號左尖括號/form右尖括號

左尖括號/body右尖括號左尖括號/html右尖括號附2:web.xml

左尖括號display-name右尖括號My Test左尖括號/display-name右尖括號

左尖括號filter右尖括號左尖括號filter-name右尖括號struts2左尖括號/filter-name右尖括號左尖括號filter-class右尖括號org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter左尖括號/filter-class右尖括號左尖括號/filter右尖括號

左尖括號filter-mapping右尖括號左尖括號filter-name右尖括號struts2左尖括號/filter-name右尖括號左尖括號url-pattern右尖括號/*左尖括號/url-pattern右尖括號左尖括號/filter-mapping右尖括號

左尖括號welcome-file-list右尖括號左尖括號welcome-file右尖括號index.html左尖括號/welcome-file右尖括號左尖括號welcome-file右尖括號index.jsp左尖括號/welcome-file右尖括號左尖括號/welcome-file-list右尖括號

左尖括號/web-app右尖括號附3:struts.xml

左尖括號?xml version="1.0" encoding="UTF-8" ?右尖括號左尖括號!DOCTYPE struts PUBLIC    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"    ""右尖括號

左尖括號struts右尖括號左尖括號package name="struts2ltl" extends="struts-default"右尖括號左尖括號action name="login" class="com.ltl.service.LoginAction"右尖括號左尖括號result name="error"右尖括號/error.jsp左尖括號/result右尖括號左尖括號result name="success"右尖括號/welcome.jsp左尖括號/result右尖括號左尖括號/action右尖括號左尖括號/package右尖括號左尖括號/struts右尖括號

附4:LoginAction.java

package com.ltl.service;

public class LoginAction {

//下面是用於封裝使用者請求引數的兩個屬性 private String username; private String password; //username屬性和password屬性的getter和setter方法 public String getUsername() {  return username; } public void setUsername(String username) {  this.username = username; } public String getPassword() {  return password; } public void setPassword(String password) {  this.password = password; } public String execute() {  if(getUsername().equals("我")    && getPassword().equals("你"))  {   return "success";  }  else  {   return "error";  } }}附5:error.jsp

左尖括號%@ page language="java" contentType="text/html; charset=UTF-8"    pageEncoding="UTF-8"%右尖括號左尖括號!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" ""右尖括號左尖括號html右尖括號左尖括號head右尖括號左尖括號meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"右尖括號左尖括號title右尖括號Insert title here左尖括號/title右尖括號左尖括號/head右尖括號左尖括號body右尖括號左尖括號a href="index.jsp"右尖括號登入失敗左尖括號/a右尖括號左尖括號/body右尖括號左尖括號/html右尖括號

附6:welcome.jsp

左尖括號%@ page language="java" contentType="text/html; charset=UTF-8"    pageEncoding="UTF-8"%右尖括號左尖括號!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" ""右尖括號左尖括號html右尖括號左尖括號head右尖括號左尖括號meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"右尖括號左尖括號title右尖括號Insert title here左尖括號/title右尖括號左尖括號/head右尖括號左尖括號body右尖括號左尖括號a href="index.jsp"右尖括號登入成功左尖括號/a右尖括號左尖括號/body右尖括號左尖括號/html右尖括號

附7:build.xml

左尖括號?xml version="1.0" encoding="UTF-8"?右尖括號左尖括號project name="ant_firsttest" default="compile" basedir="."右尖括號左尖括號description右尖括號ant firsttest!左尖括號/description右尖括號左尖括號!-- set global properties for this build --右尖括號左尖括號!--設定變數,之後用。location為資料夾路徑--右尖括號左尖括號property name="src" location="src"/右尖括號左尖括號property name="root" location="."/右尖括號左尖括號property name="lib"  location="lib"/右尖括號左尖括號!--設定properties檔案位置.這裡沒用到。--右尖括號左尖括號!--左尖括號property file="nbproject/project.properties"/右尖括號--右尖括號

左尖括號!--初始化命令--右尖括號左尖括號target name="init"右尖括號左尖括號!-- Create the time stamp --右尖括號左尖括號tstamp/右尖括號左尖括號!--mkdir是建立資料夾,${build}即剛才設定的變數。這幾行都在幹這事。--右尖括號左尖括號!-- Create the build directory structure used by compile --右尖括號左尖括號mkdir dir="${root}/WEB-INF/lib"/右尖括號左尖括號mkdir dir="${root}/WEB-INF/classes/com/ltl/service"/右尖括號左尖括號/target右尖括號

左尖括號!--編譯--右尖括號左尖括號target name="compile" depends="init"                                            description="compile the source " 右尖括號左尖括號!-- Compile the java code from ${src} into ${build} --右尖括號左尖括號!--javac標籤用來設定編譯程式的引數,srcdir為java檔案路徑,destdir為編譯後class檔案的儲存路徑。--右尖括號左尖括號javac srcdir="${src}" destdir="${root}/WEB-INF/classes/"/右尖括號左尖括號!--如果路徑下還有別的檔案需要一起打包,用copy 命令。--右尖括號左尖括號copy file="${src}/struts.xml" tofile="${root}/WEB-INF/classes/struts.xml" /右尖括號左尖括號copydir src="${lib}" dest="${root}/WEB-INF/lib" /右尖括號左尖括號/target右尖括號左尖括號!--刪除--右尖括號左尖括號target name="clean"                                            description="clean up" 右尖括號左尖括號!--設定刪除命令要刪的路徑。--右尖括號左尖括號!-- Delete the ${build} and ${dist} directory trees --右尖括號左尖括號delete dir="${src}"/右尖括號左尖括號delete dir="${lib}"/右尖括號左尖括號/target右尖括號左尖括號/project右尖括號

相關推薦

ant部署struts2開發環境

1.安裝部署jdk,安裝部署tomcat伺服器,下載安裝ant構建工具,下載struts2的jar檔案 2.在電腦上新建一個資料夾test,在test資料夾下新建目錄lib、src、WEB-INF,在test資料夾下新建檔案index.jsp(見附1) 3.所有網站都要有web.xml檔案。從t

Centos7.2部署Java開發環境

$path 2.x ava x64 jdk server telnet 選擇 new 1.安裝JDK   如果以前安裝過JDK,想要重新安裝可執行如下命令進行卸載,這裏安裝的是JDK1.8:   先查詢: rpm -qa|grep jdk   然後再通過下面命令進行卸載

在Ubuntu部署Vue開發環境(詳細流程)

在Ubuntu下部署Vue環境(非常詳細流程) 我們的需求是使用vue進行前後端分離開發,本節目標是為了能夠使用npm run dev將我們的前端專案執行起來 我們需要的是nodejs、npm、cnpm、webpack、vue 我的Ubuntu版本: elementoryOS 5 (基於Ubuntu

Struts2】eclipse 搭建 Struts2 開發環境

 eclipse的第一個struts2外掛 Alveole Studio MVC Web Project     An eclipse plugin for   Struts 2    -------- 官方地址 http://mvcwebproject.sourcefor

Eclipse搭建Struts2開發環境

最近下載了最新的struts 2.06,在使用其中附帶的例子時,在配置上遇到了一些問題。 經過很多次的努力後,終於配置成功。現在把配置過程寫出來供大家參考! 一 軟體:1 Eclipse+lomboz  3.2 2 Tomcat 5.5 3 JDK 6

使用ant手動搭建struts2開發環境

1.安裝部署jdk,安裝部署tomcat伺服器,下載struts2的jar檔案 2.在電腦上新建一個資料夾test,在test資料夾下新建目錄lib、src、WEB-INF                                                              

UbuntuLaravel的開發環境安裝及部署(Vagrant + Homestead)

2018-2-6 更新 注意! laravel/homestead box專案地址已經不再是原來的 https://atlas.hashicorp.com/laravel/boxes/homestead,而已經變更成 https://app.vagrantup.com/laravel/

Linux搭建Python開發環境部署

1.安裝作業系統 系統版本CentOS release 6.5 (Final)mini安裝 關閉SELinux 關閉防火牆功能 關閉SSH的UseDNS功能 配置IP地址 配置DNS伺服器 配置NTP伺服器 配置主機名   2. Pyenv安裝方式 2.1

window使用Docker部署前端開發環境

背景 很早之前就關注過docker,看過有關的資料,但是那時候docker並不支援window,使用需要使用 docker toolbox 採用VirtualBox虛擬機器的方式來安裝,覺得很麻煩,就一直沒有嘗試。 最近無意中發現docker for windo

在Windows搭建Android開發環境

c51 公司 智能 單獨 window 引用 ssp 管理 第一個  隨著移動互聯網的迅速發展,前端的概念已發生很大的變化,已不僅僅局限在網頁端。而Android系統作為智能機市場的老大,作為前端開發工程師,非常有必要了解和學習。但面對眾多學習資料,站在前端開發工程

Python開發入門Windows搭建python開發環境

python開發入門 Python是一種高級計算機程序設計語言。舉個例子C語言要寫1000行代碼,Java只需要寫100行,而Python可能只要20行。 Python基本概念 Python(英語發音:/?pa?θ?n/), 是一種面向對象、解釋型計算機程序設計語言,由Guido van R

linux 安裝web開發環境

技術 cnblogs -- 時間日誌 java inux 協議 環境變量 含義 以下使用 linux centos系統 一、JDK的安裝 1、下載jdk-8u111-linux-x64.tar.gz 2、解壓該文件,將解壓後的文件復制到 /usr/local/jdk1.7

WIN10java8的開發環境配置

java win10 環境變量WIN10下java8的開發環境配置一.開發環境配置 1.在官網上下載jdk-8u111-windows-x64.exe 註:jdk1.7下載地址 2.運行安裝包,可以自定義安裝路徑 3.進入環境變量設置: 計算機右鍵-->屬性-->高級系統設置-->環境變量

在mac搭建java開發環境

$path java ide new 版本 word-wrap 開發工具 profile data- 剛剛從windows系統轉到使用mac系統。感覺不是特別熟悉,須要一定的適應時間。以下簡介一下mac下搭建主要的java開發環境。 1.安裝jdk 安裝jdk1

Win7 OpenCV+Qt開發環境搭建

tro enc 銷毀 vid 使用 detect ack text [] 1、所需軟件工具: (1)OpenCV開發庫,2.4.9版;包括源文件(source文件夾)和編譯後的文件(build文件夾),但最好自己使用CMake又一次編譯。否則easy出錯。 (2

Struts2開發環境搭建

clas -1 sources classes 提示 res style web.xml sse 1.導入jar包:復制Struts\apps\struts2-blank\WEB-INF\lib下的所有jar包到當前項目的lib文件夾下 2.在web.xml文件中

ESP32搭建3.ubuntu14.04搭建esp32開發環境 (最新版)

終端 pat 權限 技術 實例 為我 tro component 直接 硬件為樂鑫出品的ESP32一款集成了wifi和藍牙的集成模塊。 1.首先ctrl+alt+t打開終端,sudo -s選擇用root權限登陸 。 2. 輸入指令:sudo apt-get install

Mac 的 C++ 開發環境

log 同時 文件包含 修改 專註 strong 2.3 evel 當前 1. Xcode 創建 C++ 項目 Xcode (版本 4.6.3)默認支持創建 C++ 項目,步驟很簡單:打開 Xcode,新建一個項目;在 OS X 中的 Application 中選擇 Com

Linux搭建STM8開發環境

post get des apt b- blog div 復制 bsp 使用SDCC+STM8Flash+STLink搭建Linux開發STM8開發環境,對應的MCS51,LPC之類的也可以使用SDCC 1、安裝SDCC$ sudo apt-get install sdcc

如何部署struts開發環境

代碼 lis 映射 測試 schema png prop ont 選擇 1 首先登陸http://archive.apache.org/dist/struts/source/頁面,會看到struts的下載頁面 2 下載struts的最新版本struts2-2.2.1-src