Struts2入門詳解
如何搭建Struts2專案
匯入相關架包
編寫web.xml,配置strus2過濾器
<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>
編寫Struts2配置檔案struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<package name="default" namespace="/user" extends="struts-default">
<action name="regist" class="cn.itcast.action.RegistAction">
<result name="input">/success.jsp</result>
</action>
</package>
</struts >
訪問路徑 /user/regist.action
name 包名稱,在struts2的配置檔案檔案中 包名不能重複 ,name並不是真正包名,只是為了管理Action
namespace 和 action的name屬性,決定 Action的訪問路徑 (以/開始 )
extends 繼承哪個包,通常開發中繼承 struts-default 包 (struts-default包在 struts-default.xml定義 )
繼承struts-default包後,可以使用 包中定義攔截器和結果型別
action元素配置預設值
package 的namespace 預設值‘’‘’
action 的class 預設值 ActionSupport 類
result 的 name 預設值 success
預設Action 和 Action的預設處理類
1) 預設Action , 解決客戶端訪問Action不存在的問題 ,客戶端訪問Action, Action找不到,預設Action 就會執行
2) 預設處理類 ,客戶端訪問Action,已經找到匹配元素,但是元素沒有class屬性,執行預設處理類
* 在struts-default.xml 配置預設處理類 ActionSupport
Struts2的常量配置
1) struts2 預設常量 在 default.properties 中配置
2) 開發者自定義常量
struts.xml
格式 : <constant name="struts.devMode" value="true" />
struts.properties
格式 : struts.devMode = true
web.xml
格式 :
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
<init-param>
<param-name>struts.devMode</param-name>
<param-value>true</param-value>
</init-param>
</filter>
3) 常用常量
<constant name="struts.i18n.encoding" value="UTF-8"/> ----- 相當於request.setCharacterEncoding("UTF-8"); 解決post請求亂碼
<constant name="struts.action.extension" value="action"/> --- 訪問struts2框架Action訪問路徑 副檔名 (要求)
struts.action.extension=action, 預設以.action結尾副檔名 和 不寫副檔名 都會分發給 Action
<constant name="struts.serve.static.browserCache" value="false"/> false不快取,true瀏覽器會快取靜態內容,產品環境設定true、開發環境設定false
<constant name="struts.devMode" value="true" /> 提供詳細報錯頁面,修改struts.xml後不需要重啟伺服器
Action
Action書寫的的三種格式
第一種
Action可以是 POJO ((PlainOldJavaObjects)簡單的Java物件) —- 不需要繼承任何父類,實現任何介面
* struts2框架 讀取struts.xml 獲得 完整Action類名
* obj = Class.forName(“完整類名”).newInstance();
* Method m = Class.forName(“完整類名”).getMethod(“execute”); m.invoke(obj); 通過反射 執行 execute方法
第二種
編寫Action 實現Action介面
Action介面中,定義預設五種 邏輯檢視名稱
public static final String SUCCESS = “success”; // 資料處理成功 (成功頁面)
public static final String NONE = “none”; // 頁面不跳轉 return null; 效果一樣
public static final String ERROR = “error”; // 資料處理傳送錯誤 (錯誤頁面)
public static final String INPUT = “input”; // 使用者輸入資料有誤,通常用於表單資料校驗 (輸入頁面)
public static final String LOGIN = “login”; // 主要許可權認證 (登陸頁面)
五種邏輯檢視,解決Action處理資料後,跳轉頁面
第三種
編寫Action 繼承ActionSupport (推薦)
在Action中使用 表單校驗、錯誤資訊設定、讀取國際化資訊 三個功能
Action的配置method(萬用字元)
1) 在配置 元素時,沒有指定method屬性, 預設執行 Action類中 execute方法
2)使用萬用字元* ,簡化struts.xml配置
<a href="${pageContext.request.contextPath }/user/customer_add.action">新增客戶</a>
<a href="${pageContext.request.contextPath }/user/customer_del.action">刪除客戶</a>
struts.xml
<action name="customer_*" class="cn.itcast.struts2.demo4.CustomerAction" method="{1}"></action> --- {1}就是第一個* 匹配內容
動態方法呼叫
訪問Action中指定方法,不進行配置
1) 在工程中使用 動態方法呼叫 ,必須保證 struts.enable.DynamicMethodInvocation = true 常量值 為true
2) 在action的訪問路徑 中 使用 “!方法名”
頁面
<a href="${pageContext.request.contextPath }/user/product!add.action">新增商品</a>
配置
<action name="product" class="cn.itcast.struts2.demo4.ProductAction"></action>
執行 ProductAction 中的 add方法
Action訪問Servlet API
1、 在Action 中解耦合方式 間接訪問 Servlet API ——— 使用 ActionContext 物件
在struts2 中 Action API 已經與 Servlet API 解耦合 (沒有依賴關係 )
* Servlet API 常見操作 : 表單提交請求引數獲取,向request、session、application三個範圍存取資料
actionContext = ActionContext.getContext();
1) actionContext.getParameters(); 獲得所有請求引數Map集合
2) actionContext.put(“company”, “傳智播客”); / actionContext.get(“company”) 對request範圍存取資料
3) actionContext.getSession(); 獲得session資料Map,對Session範圍存取資料
4) actionContext.getApplication(); 獲得ServletContext資料Map,對應用訪問存取資料
2、 使用介面注入的方式,操作Servlet API (耦合)
1.要求action類必須實現提定介面。
ServletContextAware : 注入ServletContext物件
ServletRequestAware :注入 request物件
ServletResponseAware : 注入response物件
2.重定介面中的方法。
private HttpServletRequest request;
3.宣告一個web物件,使用介面中的方法的引數對宣告的web物件賦值.
public void setServletRequest(HttpServletRequest request) {
this.request = request;
}
3、 在Action中直接通過 ServletActionContext 獲得Servlet API
ServletActionContext.getRequest() : 獲得request物件 (session)
ServletActionContext.getResponse() : 獲得response 物件
ServletActionContext.getServletContext() : 獲得ServletContext物件
ServletActionContext.getPageContext().getSession(); //獲取session等物件
Action處理請求引數
第一種 :Action 本身作為model物件,通過成員setter封裝 (屬性驅動 )
頁面:
使用者名稱 <input type="text" name="username" />
Action :
public class RegistAction1 extends ActionSupport {
private String username;
public void setUsername(String username) {
this.username = username;
}
}
第二種 :建立獨立model物件,頁面通過ognl表示式封裝 (屬性驅動)
頁面:
使用者名稱 <input type="text" name="user.username" />----- 基於OGNL表示式的寫法
Action:
public class RegistAction2 extends ActionSupport {
private User user;
public void setUser(User user) {
this.user = user;
}
public User getUser() {
return user;
}
}
使用ModelDriven介面,對請求資料進行封裝 (模型驅動 ) —– 主流
頁面:
使用者名稱 <input type="text" name="username" /> <br/>
Action :
public class RegistAction3 extends ActionSupport implements ModelDriven<User> {
private User user = new User(); // 必須手動例項化
public User getModel() {
return user;
}
}
封裝資料到Collection和Map
1) 封裝資料到Collection 物件
頁面:
產品名稱 <input type="text" name="products[0].name" /><br/>
Action :
public class ProductAction extends ActionSupport {
private List<Product> products;
public List<Product> getProducts() {
return products;
}
public void setProducts(List<Product> products) {
this.products = products;
}
}
2) 封裝資料到Map 物件
頁面:
產品名稱 <input type="text" name="map['one'].name" /><br/> ======= one是map的鍵值
Action :
public class ProductAction2 extends ActionSupport {
private Map<String, Product> map;
public Map<String, Product> getMap() {
return map;
}
public void setMap(Map<String, Product> map) {
this.map = map;
}
}
請求引數校驗
手工程式碼校驗請求引數
步驟一: 封裝資料
步驟二: 實現校驗Action ,必須繼承ActionSupport 類
步驟三: 覆蓋validate方法,完成對Action的業務方法 資料校驗通過程式碼邏輯判斷引數是否有效,如果引數非法 , this.addFieldError (ActionSupport提供)workflow攔截器 跳轉回 input頁面
步驟四: 在jsp中 通過 s:fieldError 顯示錯誤資訊
validate方法會對Action中所有業務方法進行校驗,如果只想校驗某一個方法 : validate方法名()
Xml配置方式資料校驗
位置:xml檔案要與action類在同一個包下
名稱:action類名-validation.xml(針對某個方法效驗UserAction-regist-validation.xml)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE validators PUBLIC
"-//Apache Struts//XWork Validator 1.0.3//EN"
"http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd">
<validators>
<!-- 對username屬性進行校驗 -->
<field name="username">
<!-- 指定username不能為空 -->
<field-validator type="requiredstring">
<!-- 錯誤資訊 -->
<message>使用者名稱不能為空--------</message>
</field-validator>
<!-- 長度校驗,規定使用者名稱必須在6-10位之間 -->
<field-validator type="stringlength">
<param name="maxLength">10</param>
<param name="minLength">6</param>
<message>使用者名稱必須在${minLength}-${maxLength}位之間</message>
</field-validator>
</field>
<!-- 對age進行校驗,規定年齡必須在10-40之間 -->
<field name="age">
<field-validator type="int">
<param name="min">10</param>
<param name="max">40</param>
<message>年齡必須在${min}--${max}之間</message>
</field-validator>
</field>
<!-- 對birthday進行校驗 -->
<field name="birthday">
<field-validator type="date">
<param name="min">1974-01-01</param>
<param name="max">2004-12-31</param>
<message>生日必須在${min}年到${max}年之間</message>
</field-validator>
</field>
<!-- 校驗郵箱 -->
<field name="email">
<field-validator type="email">
<message>郵箱格式不正確</message>
</field-validator>
</field>
<!-- url校驗 -->
<field name="url">
<field-validator type="url">
<message>url不能這空,類似於http://www.baidu.com</message>
</field-validator>
</field>
<!-- 使用正則 -->
<field name="telphone">
<field-validator type="regex">
<param name="regexExpression"><![CDATA[^135[0-9]{8}$]]></param>
<message>電話號碼必須是135xxxxxxxx</message>
</field-validator>
</field>
<field name="repassword">
<field-validator type="fieldexpression">
<param name="expression"><![CDATA[(password==repassword)]]></param>
<message>兩次密碼輸入不一致</message>
</field-validator>
</field>
</validators>
內建校驗器
* required (必填校驗器,要求被校驗的屬性值不能為null)
* requiredstring (必填字串校驗器,要求被校驗的屬性值不能為null,並且長度大於0,預設情況下會對字串去前後空格)
* stringlength (字串長度校驗器,要求被校驗的屬性值必須在指定的範圍內,否則校驗失敗,minLength引數指定最小長度,maxLength引數指定最大長度,trim引數指定校驗field之前是否去除字串前後的空格)
* regex (正則表示式校驗器,檢查被校驗的屬性值是否匹配一個正則表示式,expression引數指定正則表示式,caseSensitive引數指定進行正則表示式匹配時,是否區分大小寫,預設值為true)
* int(整數校驗器,要求field的整數值必須在指定範圍內,min指定最小值,max指定最大值)
* double(雙精度浮點數校驗器,要求field的雙精度浮點數必須在指定範圍內,min指定最小值,max指定最大值)
* fieldexpression (欄位OGNL表示式校驗器,要求field滿足一個ognl表示式,expression引數指定ognl表示式,該邏輯表示式基於ValueStack進行求值,返回true時校驗通過,否則不通過)
* email(郵件地址校驗器,要求如果被校驗的屬性值非空,則必須是合法的郵件地址)
* url(網址校驗器,要求如果被校驗的屬性值非空,則必須是合法的url地址)
* date(日期校驗器,要求field的日期值必須在指定範圍內,min指定最小值,max指定最大值)
Result結果型別
Action處理請求後, 返回字串(邏輯檢視名), 需要在struts.xml 提供 元素定義結果頁面
1、 區域性結果頁面 和 全域性結果頁面
<action name="result" class="cn.itcast.struts2.demo6.ResultAction">
<!-- 區域性結果 當前Action使用 -->
<result name="success">/demo6/result.jsp</result>
</action>
<global-results>
<!-- 全域性結果 當前包中 所有Action都可以用-->
<result name="success">/demo6/result.jsp</result>
</global-results>
2、 結果頁面跳轉型別
result標籤
1.name 與action中的method的返回值匹配,進行跳轉.
2.type 作用:是用於定義跳轉方式
dispatcher:它代表的是請求轉發,也是預設值。它一般用於從action跳轉到頁面。
chain:它也相當於請求轉發。它一般情況下用於從一個action跳轉到另一個action。
<!--hello是一個Action的name-->
<result name="success" type="chain">hello</result>
redirect:它代表的是重定向 它一般用於從action跳轉到頁面
redirectAction: 它代表的是重定向 它一般用於從action跳轉另一個action。
<result name="success" type="redirectAction">hello</result>
stream:代表的是伺服器端返回的是一個流,一般用於下載。
在jsp中顯示錯誤資訊
<s:fieldError/>
<s:fielderror fieldName="">展示特定名稱的錯誤資訊.
Struts2國際化
資原始檔編寫
properties檔案命名 : 基本名稱語言(小寫)國家(大寫).properties
編寫3個property檔案
message.properties
name=tom
messages_zh_CN.properties //中國中文
name=湯姆
messages_en_US.properties //美國英文
name=tom
資原始檔作用域
1.針對於action類
位置:與action類在同一個包下.
名稱:ActionClassName.properties.
這個配置檔案只對當前action有效。
2.針對於package下所有action
位置:在指定的包下
名稱:package.properties
怎樣使用
1.在action類中使用
前提:action類要繼承ActionSupport類。
getText(String name)就可以獲取配置檔案中對應名稱的值。
2.在validation.xml檔案中使用
<message key="名稱"/>
3.在jsp頁面上使用
s:text name=”名稱” 如果沒有使用s:i18n name=”“來指定,會從全域性配置檔案中獲取。
如果要從某一個配置檔案中獲取,通過name屬性來指定, 包名.配置檔名稱 .
<s:i18n name="cn.itcast.action.package">
<s:text name="nameerror"/>
</s:i18n>
在struts2中國際化配置檔案中使用動態文字
1.action中怎樣使用
xxxx.property
msg=hello world {0}
action
this.getText("msg",new String[]{"tom"})
結果就是 hello world tom
2.jsp頁面上怎樣使用
xxxx.property
msg=hello world {0}
<s:i18n name="cn.itcast.action.I18nDemo1Action">
<s:text name="msg">
<s:param>張三</s:param>
</s:text>
</s:i18n>
結果就是 hello world 張三
Struts2攔截器
struts2中在struts-default.xml檔案中聲明瞭所有的攔截器。
而struts2框架預設使用的是defaultStack這個攔截器棧。
在這個攔截器棧中使用了18個攔截器。簡單說,struts2框架
在預設情況下,載入了18個攔截器。
注意:只要顯示宣告使用了一個攔截器。那麼預設的攔截器就不在載入。
常用struts2 攔截器
<interceptor-ref name="modelDriven"/> 模型驅動
<interceptor-ref name="fileUpload"/> 檔案上傳
<interceptor-ref name="params"> 引數解析封裝
<interceptor-ref name="conversionError"/> 型別轉換錯誤
<interceptor-ref name="validation"> 請求引數校驗
<interceptor-ref name="workflow"> 攔截跳轉 input 檢視
自定義攔截器
struts.xml
<interceptors>
<interceptor name="my" class="cn.itcast.intercept.MyInterceptor">
</interceptor>
<interceptor name="bookInterceptor" class="cn.itcast.intercept.BookInterceptor">
<param name="includeMethods">add,update,delete</param>
</interceptor>
<interceptor-stack name="myStack">
<interceptor-ref name="bookInterceptor"></interceptor-ref>
<interceptor-ref name="defaultStack" />
</interceptor-stack>
</interceptors>
<action name="demo1" class="cn.itcast.action.Demo1Action">
<result name="login">/login.jsp</result>
<!-- <interceptor-ref name="my" /> <interceptor-ref name="defaultStack"/> -->
<interceptor-ref name="myStack" />
</action>
action
public class BookInterceptor extends MethodFilterInterceptor {
@Override
protected String doIntercept(ActionInvocation invocation) throws Exception {
// 1.得到session中的user
User user = (User) ServletActionContext.getRequest().getSession().getAttribute("user");
if (user == null) {
BookAction action = (BookAction) invocation.getAction(); // 得到當前攔截的action物件。
action.addActionError("許可權不足,請先登入");// 儲存錯誤資訊
return Action.LOGIN;
}
return invocation.invoke();
}
}
OGNL表示式和值棧
值棧在開發中應用
主流應用 : 值棧 解決 Action 向 JSP 傳遞 資料問題
Action 向JSP 傳遞資料處理結果 ,結果資料有兩種形式
1) 訊息 String型別資料
this.addFieldError("msg", "欄位錯誤資訊");
this.addActionError("Action全域性錯誤資訊");
this.addActionMessage("Action的訊息資訊");
- fieldError 針對某一個欄位錯誤資訊 (常用於表單校驗)、actionError (普通錯誤資訊,不針對某一個欄位 登陸失敗)、 actionMessage 通用訊息
在jsp中使用 struts2提供標籤 顯示訊息資訊
<s:fielderror fieldName="msg"/>
<s:actionerror/>
<s:actionmessage/>
2) 資料 (複雜型別資料)
使用值棧
valueStack.push(products);
哪些資料預設會放入到值棧 ???
1)每次請求,訪問Action物件 會被壓入值棧 ——- DefaultActionInvocation 的 init方法 stack.push(action);
* Action如果想傳遞資料給 JSP,只要將資料儲存到成員變數,並且提供get方法就可以了
2)ModelDriven 介面 有一個單獨攔截器
在攔截器中 ,將model物件 壓入了 值棧 stack.push(model);
* 如果Action 實現ModelDriven介面,值棧預設棧頂物件 就是model物件
OGNL表示式 常見使用
、 % 、$ 符號使用
1) # 的 使用
用法一 # 代表 ActionContext.getContext() 上下文
<s:property value="#request.name" /> ------------> ActionContext().getContext().getRequest().get("name");
#request
#session
#application
#attr
#parameters
用法二 : 不寫# 預設在 值棧中root中進行查詢
<s:property value="name" /> 在root中查詢name屬性
查詢元素時,從root的棧頂元素 開始查詢, 如果訪問指定棧中元素
<s:property value="[1].name" /> 訪問棧中第二個元素name屬性
訪問第二個元素物件
<s:property value="[1].top" />
用法三 :進行投影對映 (結合複雜物件遍歷 )
1)集合的投影(只輸出部分屬性
遍歷集合只要name屬性
<s:iterator value="products.{name}" var="pname">
<s:property value="#pname"/>
</s:iterator>
2)遍歷時,對資料設定條件
遍歷集合只要price大於1500商品
<s:iterator value="products.{?#this.price>1500}" var="product">
<s:property value="#product.name"/> --- <s:property value="#product.price"/>
</s:iterator>
3)綜合
只顯示價格大於1500 商品名稱
<s:iterator value="products.{?#this.price>1500}.{name}" var="pname">
<s:property value="#pname"/>
</s:iterator>
用法四: 使用#構造map集合
經常結合 struts2 標籤用來生成 select、checkbox、radio
使用#構造map集合 遍歷
<s:iterator value="#{'name':'aaa','age':'20', 'hobby':'sport' }" var="entry">
key : <s:property value="#entry.key"/> , value: <s:property value="#entry.value"/> <br/>
</s:iterator>
2) %的使用
<s:property value="表示式">
對於s:property標籤,它的value屬性會被預設做為ognl.
用法一: 結合struts2 表單使用, 通過%通知struts, %{}中內容是一個OGNL表示式,進行解析
<s:textfield name="username" value="%{#request.username}"/>
用法二: 設定ognl表示式不解析 %{‘ognl表示式’}
<s:property value="%{'#request.username'}"/>
3)$
的使用
用法一 :用於在國際化資原始檔中,引用OGNL表示式 在properties檔案 msg=歡迎您${#request.username}
在頁面
<s:i18n name="messages">
<s:text name="msg"></s:text>
</s:i18n>
* 自動將值棧的username 結合國際化配置資訊顯示
用法二 :在Struts 2配置檔案中,引用OGNL表示式
<!-- 在Action 提供 getContentType方法 -->
<param name="contentType">${contentType}</param>
{contentType} 讀取值棧中contentType資料,在Action提供 getContentType 因為Action物件會被壓入值棧, contentType是Action屬性,從值棧獲得
結論: #使用ognl表示式獲取資料,% 控制ognl表示式是否解析 ,$ 用於配置檔案獲取值棧的資料
使用OGNL訪問 物件方法 和 靜態方法
OGNL 在jsp 結合 struts2 標籤庫 使用 , <s:property value="ognl表示式" />
執行 ognl表示式
呼叫 例項方法 : 物件.方法() —- <s:property value="'hello,world'.length()"/>
呼叫 靜態方法 : @[類全名(包括包路徑)]@[方法名] — <s:property value="@[email protected]('您好,%s','小明')"/>
使用 靜態方法呼叫 必須 設定 struts.ognl.allowStaticMethodAccess=true
Struts2 防止表單重複提交
1、 在jsp 通過 <s:token />
生成令牌號
生成表單隱藏域
將令牌號儲存到Session
2、 通過struts2 提供 tokenIntercetor 攔截器 完成請求中令牌號 和 session中令牌號 比較
<interceptor name="token" class="org.apache.struts2.interceptor.TokenInterceptor"/>
<action name="token" class="cn.itcast.struts2.TokenAction">
<result>/index.jsp</result>
<!-- 重新定義攔截器 -->
<interceptor-ref name="defaultStack"></interceptor-ref>
<interceptor-ref name="token"></interceptor-ref>
</action>
3、 當表單重複提交時,token攔截器自動跳轉 result name=”invalid.token”
通過 顯示錯誤資訊
覆蓋重複提交資訊 struts.messages.invalid.token=您已經重複提交表單,請重新整理後重試
Struts2 內建json外掛
1.匯入json外掛包
在struts2的lib包下 struts2-json-plugin-2.3.15.1.jar。
2.在struts.xml檔案中配置
1.<package extends="json-default">
2.設定檢視<result type="json">
這樣設定後,會將valueStack棧頂資料變成json。
對於我們的程式,也就是會將action物件轉換成json。
設定只將指定的資料轉json
<param name="root">p</param>
如果沒有設定,可以理解成將整個action都轉換成json的資料。也就是
在action中提供的getXxx方法,就是json中的一個屬性。
如果設定了root,那麼,只將指定資料轉換成json.
怎樣設定轉換成json的物件中不包含特定的屬性?
- @JSON(serialize=false) 在getXxx方法上設定
還可以通過json外掛的interceptor完成.
設定只展示products的name屬性<param name="includeProperties">products\[\d+\]\.name</param>
相關推薦
Struts2入門詳解
如何搭建Struts2專案 匯入相關架包 編寫web.xml,配置strus2過濾器 <filter> <filter-name>struts2</filter-name>
Asp.Net MVC3 簡單入門詳解過濾器Filter
添加 重復 權限 組件 再次 ace text ext 開發 前言 在開發大項目的時候總會有相關的AOP面向切面編程的組件,而MVC(特指:Asp.Net MVC,以下皆同)項目中不想讓MVC開發人員去關心和寫類似身份驗證,日誌,異常,行為截取等這部分重復的代碼,那我們可以
線段樹 入門詳解
ear 接下來 數組 編譯器 一位 離散化 都是 並且 建立 概念(copy度娘): 線段樹是一種二叉搜索樹,與區間樹相似,它將一個區間劃分成一些單元區間,每個單元區間對應線段樹中的一個葉結點。 使用線段樹可以快速的查找某一個節點在若幹條線段中出現的次數,時間復雜度為O
Struts2 配置詳解
name con 默認 -name 動態 redirect man 執行過程 struts 1.Struts2登錄執行過程 頁面發送請求->核心控制器(StrutsPrepareAndEecuteFileter) ->Action->Result->
PHP基礎入門詳解(一)【世界上最好用的編程語言】
轉換成 c語言 127.0.0.1 mac const 讀取 成對 後臺 isset 簡介 --------- PHP(超文本預處器)是一種通用開源腳本語言。語法吸收了C語言、Java和Perl的特點,利於學習,使用廣泛,主要適用於Web開發領域。PHP 獨
Selenium Grid分布式測試入門詳解
lena 客戶端 odi before ons cycle lean efault 命令 本文對Selenium Grid進行了完整的介紹,從環境準備到使用Selenium Grid進行一次完整的多節點分布式測試。 運行環境為Windows 10,Selenium版本為
Struts2配置詳解
method software ext.get 不存在 相同 patch ant name屬性 調用 1.Namespace 1)namespace決定action的訪問路徑,默認為“”,可以接受所有路徑的Action;
01-struts2配置詳解
調試 dev efault nbsp config patch 錯誤 public include 1 struts.xml配置詳解 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts P
無向圖的割頂和橋,無向圖的雙連通分量入門詳解及模板 -----「轉載」
dbr break nts word 否則 mark push gravity 無向連通圖 https://blog.csdn.net/stillxjy/article/details/70176689 割頂和橋:對於無向圖G,如果刪除某個節點u後,連通分量數目
linux三劍客之sed入門詳解
linux 三劍客 sed sed介紹sed流編輯器(stream editor),在三劍客中排行老二,是一款簡單的文本編輯語言。sed並不直接處理源文件,而是逐行讀取源文件的內容到內存(稱模式空間)中,然後在模式空間中使用sed命令處理,再打印模式空間處理後的內容到標準輸出。sed的能夠實現的功
生成函數(母函數)入門詳解
參考 nsh 意義 數值 tar 得到 再次 fin 表達式 本文章從以上兩位大佬的博客參考而來!再次感謝! 母函數,又稱生成函數,是ACM競賽中經常使用的一種解題算法,常用來解決組合方面的題目。 在數學中,某個序列的母函數(Generating funct
樹鏈剖分入門詳解
管理 組成 你們 其它 現在 範圍 pro 所有 關系 樹鏈剖分入門詳解 以前沒有接觸過樹鏈剖分的同學們看到這個東西是不是覺得很高大上呢,下面我將帶你們進入樹的世界(講得不好別打我) 首先我們來看一道題 NOI2015D2T2軟件包管理器 題目描述如下 Linux用戶和O
區塊鏈以及區塊鏈技術入門詳解(2)
很多人迷惑於區塊鏈和以太坊,不知如何學習,本文簡單說了一下學習的一些方法和資源。 一、 以太坊和區塊鏈的關係 從區塊鏈歷史上來說,先誕生了比特幣,當時並沒有區塊鏈這個技術和名詞,然後業界從比特幣中提取了技術架構和體系,稱
區塊鏈以及區塊鏈技術入門詳解(1)
區塊鏈是目前一個比較熱門的新概念,蘊含了技術與金融兩層概念。從技術角度來看,這是一個犧牲一致性效率且保證最終一致性的的分散式的資料庫,當然這是比較片面的。從經濟學的角度來看,這種容錯能力很強的點對點網路,恰恰滿足了共享經濟的一個必須要求——低成本的可信環境。 1. 技術人員看待區塊鏈的正確姿勢
主席樹入門詳解+題目推薦
主席樹學名可持久化線段樹,就是這個可持久化,衍生了多少資料結構 為什麼會有主席樹這個資料結構呢?它被髮明是用來解決什麼問題的呢? 給定n個數,m個操作,操作型別有在某個歷史版本下單點修改,輸出某個歷史版本下某個位置的值的值,n和m小於等於1e6 乍一看是不是一點頭緒也沒有。我們先來想想暴力怎麼
經典ASP NET MVC3 0入門詳解
分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!http://blog.csdn.net/jiangjunshow 也歡迎大家轉載本篇文章。分享知識,造福人民,實現我們中華民族偉大復興!  
lambda表示式入門詳解
轉自 2018-03-02 Sevenvidia 碼農翻身 1、什麼是Lambda? 我們知道,對於一個Java變數,我們可以賦給其一個“值”。 如果你想把“一塊程式碼”賦給一個Java變數,應該怎麼做呢? 比如,我想把右邊那塊程式碼,賦給一個叫做aBlo
知識:整合營銷新手入門詳解
現在很多企業會提到整合營銷的概念。從字面理解,可能是把各種企業資源柔和在一起,發揮各自的最大化效益。整合營銷的目的是把現有的各種營銷方式進行合理化“加工”以後,再服務於企業的一種營銷策略。然而,在企業實際操作過程中,大部分經營者曲解了整合營銷的出發點,知道整合營銷很好,都在積極嘗試,但在嘗試
Spring Security 入門詳解
Spring Security 入門詳解 1.Spring Security介紹 Spring Security是基於spring的應用程式提供宣告式安全保護的安全性框架,它提供了完整的安全性解決方案,能夠在web請求級別和方法呼叫級別 處理身份證驗證和授權.它充分使用了依
linux sed使用(轉) sed入門詳解教程
sed入門詳解教程 sed 是一個比較古老的,功能十分強大的用於文字處理的流編輯器,加上正則表示式的支援,可以進行大量的複雜的文字編輯操作。sed 本身是一個非常複雜的工具,有專門的書籍講解 sed 的具體用法,但是個人覺得沒有必要去學習它的每個細節,那樣沒有特別大的實際意