<?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 這里用一句話描述這個類的作用
* @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 用一句話說明這個方法做什么
* @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">/**
* 類的構造方法
* ${tags}
*/</template></templates>
Java Web開發中,有許多共通的問題,是開發人員在開發過程中一定會遇到的,需要處理的問題:
1. 亂碼問題
為何會出現亂碼問題?既然有亂碼問題,肯定是由于編碼設置的不一致導致的。在Web開發 過程中,涉及以下一些編碼設置,客戶端參數的編碼設置,Web服務器的編碼設置,服務器端應用程序的編碼設置,數據庫的編碼設置等。只要這四處的編碼設置 有不相同的,就可能會出現亂碼問題。開發人員在進行開發之前,不防先了解一下這四個編碼在哪里設置,當前自己的項目設置是怎么樣的,這樣就可以很好的避免 編碼問題。
2. 權限控制
對于一個Java Web系統,不是所有的頁面與功能都允許所有的用戶訪問的,這樣就需要對用戶能訪問哪些頁面進行控制了。一般的Java Web系統,都需要進行權限控制。進行權限控制的方法有很多,以前看到有不少項目直接在程序里寫權限控制的代碼,這樣的弊端是顯而易見的,太不利于擴展 了,只要有任何的修改,都需要改動相當的代碼,一是容易出錯,二是修改的代價大。一個比較好的想法是基于AOP的思想,使用攔截器來進行權限控制,當然前 提是系統要配置一定的數據庫結構,如用戶-角色-權限表這樣的表結構。當然,目前有不少的權限控制開源框架如acegi
3. 參數驗證
All Input Is Evil。對于輸入參數的驗證是少不了的。對于參數的驗證,有客戶端驗證與服務器端驗證,一般來說,能夠在客戶端進行驗證的,優先考慮客戶端驗證以減少服 務器端壓力。現在有許多的Javascript框架可以很好的完成這一工作。如Jquery Validation插件。
4. 異常處理
應該說對于每個系統來說,異常處理都是很重要的。但在B/S結構的環境中,異常就顯得更為重要,一個設計良好的異常處理框架可以減少很多的代碼編寫工作。
5. 參數傳遞
在B/S結構,基于HTTP來完成通信,每一次的客戶端與服務器端的交互都是一次參數傳 遞的過程。控制參數的傳遞過程就顯得很重要了。要清楚的知道每一次的B/S的交互,需要傳遞哪些參數,哪些參數是合法的,哪些參數是不合法的,是通過 GET方式還是通過POST方式,還是通過URL鏈接的方式。
6. Ajax
現在的Java Web系統,不使用Ajax技術是不可能的了。Ajax實在是一項不錯的技術,不刷新頁面而完成與服務器端的通信,它使得基于B/S的結構功能更強大了, 許多傳統的Web應用程序所無法完成的功能現在大都可以用B/S架構來實現。對于Ajax現在已經有很多成熟的Javascript框架可以使用。首推 jQuery,其提供的Ajax功能簡單而實用。
7. 客戶端Javascript技術
客戶端技術有很多,Javascript應該說是功能最強大、應用最廣泛的一個了。用好Javascript,在系統設計時多考慮客戶端的實現方式,可以很好的輔助進行服務器端的功能設計。優秀的Javascript框架還是推薦jQuery,其功能簡單、實用而強大。
1 Visual Studio 2008 RTM && .NET Framework Version 3.5 SP1 英文版
2 Microsoft Windows Mobile 設備中心 6.1
3 Windows Mobile 6 Professional SDK Refresh.msi
4 Windows Mobile 6 Standard SDK Refresh.msi 非必需
中文模擬器下載頁面:
http://www.microsoft.com/downloads/details.aspx?familyid=38C46AA8-1DD7-426F-A913-4F370A65A582&displaylang=en
專業版中文模擬器下載地址:
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
安裝完成之后,配置開發模擬器環境:
1 設備中心 設置:文件-連接設置:允許連接到以下其中一個端口 選擇DMA
2 vs2008菜單 Tools-Device Emulator Manager- 選擇Windows Mobile 6.3.5 Professional WVGAEmulator右鍵Connect
等待刷新,然后選擇Windows Mobile 6.3.5 Professional WVGAEmulator右鍵Cradle建立同步
然后出現同步設置向導,下一步,然后根據需求完成向導。
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
* 原來的文件名
* @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()) {// 若在該目錄下已經有一個文件和新文件名相同,則刪除重建
System.out.println(newname + "已經存在!");
newfile.delete();
oldfile.renameTo(newfile);
} else {
oldfile.renameTo(newfile);
}
}
}
/**
* 創建文件夾
*
* @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>