Skynet
posts - 165, comments - 198, trackbacks - 0, articles - 1
BlogJava
::
首頁
::
新隨筆
::
聯系
::
聚合
::
管理
struct 2 apps 學習(1)
Posted on 2008-04-21 17:51
G_G
閱讀(1223)
評論(0)
編輯
收藏
所屬分類:
struct
struts2-blank-2.0.11.1.war
web.xml:
<?
xml?version="1.0"?encoding="UTF-8"
?>
<
web-app?
id
="WebApp_9"
?version
="2.4"
?xmlns
="http://java.sun.com/xml/ns/j2ee"
?xmlns:xsi
="http://www.w3.org/2001/XMLSchema-instance"
?xsi:schemaLocation
="http://java.sun.com/xml/ns/j2ee?http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
>
????
<
display-name
>
Struts?Blank
</
display-name
>
????
<
filter
>
????????
<
filter-name
>
struts2
</
filter-name
>
????????
??? <!--
?struct?2?處理類?
-->
??? <!--
相應需要jar:
??? ??? ??? ??? commons-logging-1.0.4.jar
??? ?? ?? ?? ?? freemarker-2.3.8.jar
??? ?? ?? ?? ?? ognl-2.6.11.jar
??? ??? ??? ??? struts2-core-2.0.11.1.jar
??? ?? ?? ?? ?? xwork-2.0.4.jar
??? -->
<
filter-class
>
org.apache.struts2.dispatcher.FilterDispatcher
</
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-list
>
</
web-app
>
index.html:
??? <
head
>
??? ???
<!--
?利用html?跳轉?
-->
??? ???
<
META?
HTTP-EQUIV
="Refresh"
?CONTENT
="0;URL=example/HelloWorld.action"
>
??? </
head
>
struct.xml
???
<!--
?模塊化注入??
-->
???
<
include?
file
="example.xml"
/>
????
<!--
?Add?packages?here?
-->
????
example.xml
<?
xml?version="1.0"?encoding="UTF-8"?
?>
<!
DOCTYPE?struts?PUBLIC
????????"-//Apache?Software?Foundation//DTD?Struts?Configuration?2.0//EN"
????????"http://struts.apache.org/dtds/struts-2.0.dtd"
>
<
struts
>
????
<!--
?定義域空間?
-->
????
<
package?
name
="example"
?namespace
="/example"
?extends
="struts-default"
>
????????
<!--
?域一般訪問?
-->
????????
<
action?
name
="HelloWorld"
?class
="example.HelloWorld"
>
????????????
<
result
>
/example/HelloWorld.jsp
</
result
>
????????
</
action
>
<!--
HelloWord.java(國際化) start -->
?1
?
package
?example;
?2
?
?3
?
/**
?4
?
?*?import?com.opensymphony.xwork2.ActionSupport;
?5
?
?6
?
public?class?ExampleSupport?extends?ActionSupport?{
?7
?
?
*/
?8
?
public
?
class
?HelloWorld?
extends
?ExampleSupport?{
?9
?
10
?
????
//
默認方法
11
?
????
public
?String?execute()?
throws
?Exception?{
12
?
????????
//
國際化方法使用?getText(?key?)
13
?
????????
//
?在url中體現->>?HelloWorld.action?request_locale=en/es
14
?
????????
//
國際化配置文件文件?package.properties和package_es.properties
15
?
????????setMessage(getText(MESSAGE));
16
?
????????
return
?SUCCESS;
17
?
????}
18
?
19
?
????
/**
20
?
?????*?Provide?default?valuie?for?Message?property.
21
?
?????
*/
22
?
????
public
?
static
?
final
?String?MESSAGE?
=
?
"
HelloWorld.message
"
;
23
?
24
?
????
/**
25
?
?????*?Field?for?Message?property.
26
?
?????
*/
27
?
????
private
?String?message;
28
?
29
?
????
/**
30
?
?????*?Return?Message?property.
31
?
?????*
32
?
?????*?
@return
?Message?property
33
?
?????
*/
34
?
????
public
?String?getMessage()?{
35
?
????????
return
?message;
36
?
????}
37
?
38
?
????
/**
39
?
?????*?Set?Message?property.
40
?
?????*
41
?
?????*?
@param
?message?Text?to?display?on?HelloWorld?page.
42
?
?????
*/
43
?
????
public
?
void
?setMessage(String?message)?{
44
?
????????
this
.message?
=
?message;
45
?
????}
46
?
}
<!--
HelloWord.java(國際化) end-->
???????
<!--
?(關鍵:action利用正則選擇方法)Login(_*)? >method="{1}"?
-->
????????
<
action?
name
="Login_*"
?method
="{1}"
?class
="example.Login"
>
????????????
<
result?
name
="input"
>
/example/Login.jsp
</
result
>
????????????
<
result?
type
="redirect-action"
>
Menu
</
result
>
????????
</
action
>
<!-
- example.Login(驗證框架) start -->
java
?1
?
public
?
class
?Login?
extends
?ExampleSupport?{
?2
?
?3
?
????
public
?String?execute()?
throws
?Exception?{
?4
?
?5
?
????????
if
?(isInvalid(getUsername()))?
return
?INPUT;
?6
?
?7
?
????????
if
?(isInvalid(getPassword()))?
return
?INPUT;
?8
?
?9
?
????????
return
?SUCCESS;
10
?
????}
11
?
12
?
????
private
?
boolean
?isInvalid(String?value)?{
13
?
????????
return
?(value?
==
?
null
?
||
?value.length()?
==
?
0
);
14
?
????}
Login-validation.xml
?1
?
<!
DOCTYPE?validators?PUBLIC
?2
?
????????"-//OpenSymphony?Group//XWork?Validator?1.0.2//EN"
?3
?
????????"http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"
>
?4
?
?5
?
<
validators
>
?6
?
????
<
field?
name
="username"
>
?7
?
????????
<
field-validator?
type
="requiredstring"
>
?8
?
????????????
<
message?
key
="requiredstring"
/>
?9
?
????????
</
field-validator
>
10
?
????
</
field
>
11
?
????
<
field?
name
="password"
>
12
?
????????
<
field-validator?
type
="requiredstring"
>
13
?
????????????
<
message?
key
="requiredstring"
/>
14
?
????????
</
field-validator
>
15
?
????
</
field
>
16
?
</
validators
>
17
?
<!-
- example.Login(驗證框架) end -->
????????
<!--
?jsp?封包 如:Missing.action就是Missiong.jsp
-->
????????
<
action?
name
="*"
?class
="example.ExampleSupport"
>
????????????
<
result
>
/example/{1}.jsp
</
result
>
????????
</
action
>
????????
<!--
?Add?actions?here?
-->
????
</
package
>
</
struts
>
新用戶注冊
刷新評論列表
只有注冊用戶
登錄
后才能發表評論。
網站導航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
相關文章:
struts2 ognl
struct 2 apps 學習(1)
Struts validation 小例
struts
Powered by:
BlogJava
Copyright © G_G
日歷
<
2008年4月
>
日
一
二
三
四
五
六
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
1
2
3
4
5
6
7
8
9
10
公告
由于時間問題,
blog上一些表達都不太好。
在此我盡量把我參考的原文給大家,
與大家學習。^_^
最近在維護www.tkk7.com\Skynet 腳本中
有什么技術問題不會,
我很愿意和大家討論!
多交流快成長
liukaiyi@gmail.com
常用鏈接
我的隨筆
我的評論
我的參與
最新評論
留言簿
(13)
給我留言
查看公開留言
查看私人留言
隨筆分類
ant(6)
AOP(5)
Database(9)
E_Study(3)
EJB(4)
hibernate(25)
HTML(4)
Inspiration(11)
Jakarta Commons(3)
javaGeneral(28)
javascript(28)
javascript Framework(7)
JDBC(5)
json(3)
JspTag(12)
JUnit(8)
Other(5)
Reportform(3)
Spring(4)
struct(5)
Swing(1)
xml Related(7)
隨筆檔案
2009年4月 (1)
2009年2月 (2)
2009年1月 (1)
2008年12月 (4)
2008年11月 (1)
2008年9月 (7)
2008年8月 (8)
2008年7月 (12)
2008年6月 (9)
2008年5月 (5)
2008年4月 (11)
2008年3月 (6)
2008年1月 (8)
2007年12月 (13)
2007年11月 (13)
2007年10月 (15)
2007年9月 (11)
2007年8月 (9)
2007年7月 (7)
2007年6月 (6)
2007年5月 (3)
2007年4月 (9)
文章檔案
2007年4月 (1)
相冊
EJB
hbn
ss
wz
hibernate
cjdbc
hibernate.cache
Hibernate中outer-join、lazy 、fetch join關鍵字的使用
My連接
一個讀取Gmail郵件的簡單程序
bat 1%
eXtremeTable limit
java+web
jsp java javascrip 交互
JS函數集合大全
strut c:
Struts Menu
tree jsp
上手JFreeChart
關鍵筆記
根據name調用getName方法
用JAVA實現一個分頁類
搜索
最新評論
1.?re: 序列化和反序列化對象到 數據庫
qwe
--erwqe
2.?re: 部分高級查詢 sql 拼寫筆記 (mysql)
說實話,寫的的的確是差了那么一點點
--老衲用飄柔
3.?re: html 簡單 div 拖動
好。
--火星華人
4.?re: hibernate 多服務器數據同步問題(支持延遲同步)
評論內容較長,點擊標題查看
--張久強
5.?re: 數據庫表地址數據(中國地區)
謝謝分享,收藏了!
--久久快樂鮮花
閱讀排行榜
1.?google svn 服務器使用(14275)
2.?mysql 權限控制筆記(11688)
3.?mysql 游標使用(7133)
4.?強大的 ant scp 和 sshexec (6400)
5.?CGLib 學習(5797)
評論排行榜
1.?hibernate 多服務器數據同步問題(支持延遲同步)(12)
2.?部分高級查詢 sql 拼寫筆記 (mysql)(9)
3.?為在平安夜還在加班的程序員祝福!(8)
4.?原創小框架: 動態面向對象數據庫操作(不要影射類哦)(6)
5.?自用小框架:DB工廠(6)
主站蜘蛛池模板:
亚洲色爱图小说专区
|
成人免费毛片观看
|
又长又大又粗又硬3p免费视频
|
相泽南亚洲一区二区在线播放
|
国产精品亚洲AV三区
|
久久久久久久久免费看无码
|
日韩精品亚洲专区在线观看
|
国产AV无码专区亚洲AVJULIA
|
日韩在线免费播放
|
免费精品国产自产拍观看
|
亚洲精品无码久久千人斩
|
亚洲精品久久无码av片俺去也
|
免费看内射乌克兰女
|
麻豆高清免费国产一区
|
亚洲A∨精品一区二区三区
|
有码人妻在线免费看片
|
亚洲日韩av无码
|
蜜桃成人无码区免费视频网站
|
亚洲欭美日韩颜射在线二
|
最近免费mv在线观看动漫
|
日韩中文字幕免费
|
免费人成视频在线观看免费
|
久久久精品国产亚洲成人满18免费网站
|
免费国产黄网站在线看
|
中文字幕精品亚洲无线码一区
|
亚洲人成网男女大片在线播放
|
97久久精品亚洲中文字幕无码
|
亚洲av永久无码精品漫画
|
色视频在线观看免费
|
在线观看无码的免费网站
|
久久精品国产亚洲77777
|
国产精品免费观看久久
|
www成人免费观看网站
|
国产网站在线免费观看
|
亚洲国产成人99精品激情在线
|
国产大片免费观看中文字幕
|
东方aⅴ免费观看久久av
|
亚洲av无码一区二区三区观看
|
无码日韩精品一区二区免费暖暖
|
91大神免费观看
|
久久夜色精品国产噜噜亚洲AV
|