<?xml version="1.0" encoding="UTF-8"?><templates><template autoinsert="false" context="settercomment_context" deleted="false" description="Comment for setter method" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.settercomment" name="settercomment">/**
* @param ${param} : set the property ${bare_field_name}.
*/</template><template autoinsert="false" context="filecomment_context" deleted="false" description="Comment for created Java files" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.filecomment" name="filecomment">/**
* @title ${file_name}
* @package ${package_name}
* @description 用一句話描述該文件做什么
* @author zdq
* @update ${date} ${time}
* @version V1.0
*/</template><template autoinsert="false" context="delegatecomment_context" deleted="false" description="Comment for delegate methods" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name="delegatecomment">/**
* ${tags}
* ${see_to_target}
*/</template><template autoinsert="false" context="typecomment_context" deleted="false" description="Comment for created types" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.typecomment" name="typecomment">/**
* @description 這里用一句話描述這個(gè)類的作用
* @version 1.0
* @author zdq
* @update ${date} ${time}
*/
</template><template autoinsert="false" context="overridecomment_context" deleted="false" description="Comment for overriding methods" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name="overridecomment">/* (non-Javadoc)
* ${see_to_overridden}
*/</template><template autoinsert="false" context="fieldcomment_context" deleted="false" description="Comment for fields" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name="fieldcomment">/**
* @fields ${field}
*/
</template><template autoinsert="false" context="methodcomment_context" deleted="false" description="Comment for non-overriding methods" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name="methodcomment">/**
* ${tags}
* @description 用一句話說(shuō)明這個(gè)方法做什么
* @version 1.0
* @author zdq
* @update ${date} ${time}
*/</template><template autoinsert="false" context="gettercomment_context" deleted="false" description="Comment for getter method" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name="gettercomment">/**
* @return ${bare_field_name} : return the property ${bare_field_name}.
*/</template><template autoinsert="false" context="constructorcomment_context" deleted="false" description="Comment for created constructors" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name="constructorcomment">/**
* 類的構(gòu)造方法
* ${tags}
*/</template></templates>
Java Web開(kāi)發(fā)中,有許多共通的問(wèn)題,是開(kāi)發(fā)人員在開(kāi)發(fā)過(guò)程中一定會(huì)遇到的,需要處理的問(wèn)題:
1. 亂碼問(wèn)題
為何會(huì)出現(xiàn)亂碼問(wèn)題?既然有亂碼問(wèn)題,肯定是由于編碼設(shè)置的不一致導(dǎo)致的。在Web開(kāi)發(fā) 過(guò)程中,涉及以下一些編碼設(shè)置,客戶端參數(shù)的編碼設(shè)置,Web服務(wù)器的編碼設(shè)置,服務(wù)器端應(yīng)用程序的編碼設(shè)置,數(shù)據(jù)庫(kù)的編碼設(shè)置等。只要這四處的編碼設(shè)置 有不相同的,就可能會(huì)出現(xiàn)亂碼問(wèn)題。開(kāi)發(fā)人員在進(jìn)行開(kāi)發(fā)之前,不防先了解一下這四個(gè)編碼在哪里設(shè)置,當(dāng)前自己的項(xiàng)目設(shè)置是怎么樣的,這樣就可以很好的避免 編碼問(wèn)題。
2. 權(quán)限控制
對(duì)于一個(gè)Java Web系統(tǒng),不是所有的頁(yè)面與功能都允許所有的用戶訪問(wèn)的,這樣就需要對(duì)用戶能訪問(wèn)哪些頁(yè)面進(jìn)行控制了。一般的Java Web系統(tǒng),都需要進(jìn)行權(quán)限控制。進(jìn)行權(quán)限控制的方法有很多,以前看到有不少項(xiàng)目直接在程序里寫權(quán)限控制的代碼,這樣的弊端是顯而易見(jiàn)的,太不利于擴(kuò)展 了,只要有任何的修改,都需要改動(dòng)相當(dāng)?shù)拇a,一是容易出錯(cuò),二是修改的代價(jià)大。一個(gè)比較好的想法是基于AOP的思想,使用攔截器來(lái)進(jìn)行權(quán)限控制,當(dāng)然前 提是系統(tǒng)要配置一定的數(shù)據(jù)庫(kù)結(jié)構(gòu),如用戶-角色-權(quán)限表這樣的表結(jié)構(gòu)。當(dāng)然,目前有不少的權(quán)限控制開(kāi)源框架如acegi
3. 參數(shù)驗(yàn)證
All Input Is Evil。對(duì)于輸入?yún)?shù)的驗(yàn)證是少不了的。對(duì)于參數(shù)的驗(yàn)證,有客戶端驗(yàn)證與服務(wù)器端驗(yàn)證,一般來(lái)說(shuō),能夠在客戶端進(jìn)行驗(yàn)證的,優(yōu)先考慮客戶端驗(yàn)證以減少服 務(wù)器端壓力。現(xiàn)在有許多的Javascript框架可以很好的完成這一工作。如Jquery Validation插件。
4. 異常處理
應(yīng)該說(shuō)對(duì)于每個(gè)系統(tǒng)來(lái)說(shuō),異常處理都是很重要的。但在B/S結(jié)構(gòu)的環(huán)境中,異常就顯得更為重要,一個(gè)設(shè)計(jì)良好的異常處理框架可以減少很多的代碼編寫工作。
5. 參數(shù)傳遞
在B/S結(jié)構(gòu),基于HTTP來(lái)完成通信,每一次的客戶端與服務(wù)器端的交互都是一次參數(shù)傳 遞的過(guò)程。控制參數(shù)的傳遞過(guò)程就顯得很重要了。要清楚的知道每一次的B/S的交互,需要傳遞哪些參數(shù),哪些參數(shù)是合法的,哪些參數(shù)是不合法的,是通過(guò) GET方式還是通過(guò)POST方式,還是通過(guò)URL鏈接的方式。
6. Ajax
現(xiàn)在的Java Web系統(tǒng),不使用Ajax技術(shù)是不可能的了。Ajax實(shí)在是一項(xiàng)不錯(cuò)的技術(shù),不刷新頁(yè)面而完成與服務(wù)器端的通信,它使得基于B/S的結(jié)構(gòu)功能更強(qiáng)大了, 許多傳統(tǒng)的Web應(yīng)用程序所無(wú)法完成的功能現(xiàn)在大都可以用B/S架構(gòu)來(lái)實(shí)現(xiàn)。對(duì)于Ajax現(xiàn)在已經(jīng)有很多成熟的Javascript框架可以使用。首推 jQuery,其提供的Ajax功能簡(jiǎn)單而實(shí)用。
7. 客戶端Javascript技術(shù)
客戶端技術(shù)有很多,Javascript應(yīng)該說(shuō)是功能最強(qiáng)大、應(yīng)用最廣泛的一個(gè)了。用好Javascript,在系統(tǒng)設(shè)計(jì)時(shí)多考慮客戶端的實(shí)現(xiàn)方式,可以很好的輔助進(jìn)行服務(wù)器端的功能設(shè)計(jì)。優(yōu)秀的Javascript框架還是推薦jQuery,其功能簡(jiǎn)單、實(shí)用而強(qiáng)大。
1 Visual Studio 2008 RTM && .NET Framework Version 3.5 SP1 英文版
2 Microsoft Windows Mobile 設(shè)備中心 6.1
3 Windows Mobile 6 Professional SDK Refresh.msi
4 Windows Mobile 6 Standard SDK Refresh.msi 非必需
中文模擬器下載頁(yè)面:
http://www.microsoft.com/downloads/details.aspx?familyid=38C46AA8-1DD7-426F-A913-4F370A65A582&displaylang=en
專業(yè)版中文模擬器下載地址:
http://download.microsoft.com/download/0/1/2/012bfbba-9fe5-4e68-86c9-d434446d97dd/0804/Windows%20Mobile%206%20Professional%20Images%20(CHS).msi
5 Windows Mobile 6.5 Professional Developer Tool Kit (USA).msi
6 Windows Mobile 6.5 Standard Developer Tool Kit (USA).msi 非必需
7 Windows Mobile 6.5.3 Professional DTK.msi
安裝完成之后,配置開(kāi)發(fā)模擬器環(huán)境:
1 設(shè)備中心 設(shè)置:文件-連接設(shè)置:允許連接到以下其中一個(gè)端口 選擇DMA
2 vs2008菜單 Tools-Device Emulator Manager- 選擇Windows Mobile 6.3.5 Professional WVGAEmulator右鍵Connect
等待刷新,然后選擇Windows Mobile 6.3.5 Professional WVGAEmulator右鍵Cradle建立同步
然后出現(xiàn)同步設(shè)置向?qū)В乱徊剑缓蟾鶕?jù)需求完成向?qū)А?/span>
create trigger "example1_tt" before insert
on "EXAMPLE1" for each row
declare
integrity_error exception;
errno integer;
errmsg char(200);
dummy integer;
found boolean;
begin
-- Column ""ID"" uses sequence Sequence_increase
select test_Sequence.Nextval INTO :new."ID" from dual;
-- Errors handling
exception
when integrity_error then
raise_application_error(errno, errmsg);
end;
/**
* 文件重命名
*
* @param path
* 文件目錄
* @param oldname
* 原來(lái)的文件名
* @param newname
* 新文件名
*/
public void renameFile(String path, String oldname, String newname) {
if (!oldname.equals(newname)) {
File oldfile = new File(path + "/" + oldname);
File newfile = new File(path + "/" + newname);
if (newfile.exists()) {// 若在該目錄下已經(jīng)有一個(gè)文件和新文件名相同,則刪除重建
System.out.println(newname + "已經(jīng)存在!");
newfile.delete();
oldfile.renameTo(newfile);
} else {
oldfile.renameTo(newfile);
}
}
}
/**
* 創(chuàng)建文件夾
*
* @param path
* 文件路徑
*/
public void createDir(String path) {
String pathes[] = path.split("/");
String filePath = "";
for (int i = 0; i < pathes.length; i++) {
filePath += pathes[i];
filePath += "/";
File dirPath = new File(filePath);
if (!dirPath.exists())
dirPath.mkdir();
}
}
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<!-- RichFaces tag library declaration -->
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
<html>
<f:view>
<head>
<title>JSF in Action - Validator examples</title>
</head>
<body>
<h1>
Validator examples
</h1>
<h:form>
<table border="1" cellspacing="0" cellpadding="5">
<tr>
<td>
<b>Validator(s)</b>
</td>
<td>
<b>Comments</b>
</td>
<td>
<b>Input</b>
</td>
<td>
<b>Errors</b>
</td>
</tr>
<tr>
<td>
Validation method
</td>
<td>
validator=testForm.validateEmail
</td>
<td>
<h:inputText id="methodInput"
validator="#{testForm.validateEmail}" />
</td>
<td>
<h:message for="methodInput" style="color: red" />
</td>
</tr>
<tr>
<td>
None (component property)
</td>
<td>
required="true"
</td>
<td>
<h:selectOneMenu id="RequiredInput" required="true">
<f:selectItem itemValue="" itemLabel="" />
<f:selectItem itemValue="1" itemLabel="dogs" />
<f:selectItem itemValue="2" itemLabel="birds" />
<f:selectItem itemValue="3" itemLabel="hamsters" />
</h:selectOneMenu>
</td>
<td>
<h:message for="RequiredInput" style="color: red" />
</td>
</tr>
<tr>
<td>
Length
</td>
<td>
minimum="2"
<br>
maxmimum="10"
</td>
<td>
<h:inputText id="LengthInput">
<f:validateLength minimum="2" maximum="10" />
</h:inputText>
</td>
<td>
<h:message for="LengthInput" style="color: red" />
</td>
</tr>
<tr>
<td>
LongRange
</td>
<td>
minimum="5"
<br>
maxmimum="999999"
</td>
<td>
<h:inputText id="LongRangeInput">
<f:validateLongRange minimum="5" maximum="999999" />
</h:inputText>
</td>
<td>
<h:message for="LongRangeInput" style="color: red" />
</td>
</tr>
<tr>
<td>
DoubleRange
</td>
<td>
minimum="5.1"
<br>
maxmimum="6.76"
</td>
<td>
<h:selectOneRadio id="DoubleRangeInput">
<f:selectItem itemValue="5.0" itemLabel="5.0" />
<f:selectItem itemValue="6.1" itemLabel="6.1" />
<f:selectItem itemValue="6.8" itemLabel="6.8" />
<f:validateDoubleRange minimum="5.1" maximum="6.76" />
</h:selectOneRadio>
</td>
<td>
<h:message for="DoubleRangeInput" style="color: red" />
</td>
</tr>
<tr>
<td>
Length, LongRange
</td>
<td>
required="true"
<br>
Length minimum="2"
<br>
Length maxmimum="3"
<br>
LongRange minimum="10"
<br>
LongRange maxmimum="999"
</td>
<td>
<h:inputText id="MultiInput" required="true">
<f:validateLength minimum="2" maximum="3" />
<f:validateLongRange minimum="10" maximum="999" />
</h:inputText>
</td>
<td>
<h:message for="MultiInput" style="color: red" />
</td>
</tr>
</table>
<p>
<h:commandButton value="Go!" />
</h:form>
</body>
</f:view>
</html>