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上一些表達都不太好。
在此我盡量把我參考的原文給大家,
與大家學習。^_^
最近在維護m.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 服務器使用(14274)
2.?mysql 權限控制筆記(11688)
3.?mysql 游標使用(7132)
4.?強大的 ant scp 和 sshexec (6400)
5.?CGLib 學習(5797)
評論排行榜
1.?hibernate 多服務器數據同步問題(支持延遲同步)(12)
2.?部分高級查詢 sql 拼寫筆記 (mysql)(9)
3.?為在平安夜還在加班的程序員祝福!(8)
4.?原創小框架: 動態面向對象數據庫操作(不要影射類哦)(6)
5.?自用小框架:DB工廠(6)
主站蜘蛛池模板:
国产偷国产偷亚洲清高APP
|
亚洲国产精品久久人人爱
|
国产精品亚洲一区二区无码
|
国产婷婷高清在线观看免费
|
日韩免费视频网站
|
亚洲中文字幕一二三四区
|
免费无码A片一区二三区
|
eeuss免费影院
|
国产成人毛片亚洲精品
|
国产一区二区三区免费观在线
|
亚洲乱码一区二区三区在线观看
|
国产免费牲交视频
|
四虎一区二区成人免费影院网址
|
亚洲国产精品综合久久网络
|
久久一区二区三区免费
|
久久精品亚洲日本佐佐木明希
|
最近免费中文字幕mv电影
|
亚洲偷自精品三十六区
|
四虎国产精品免费永久在线
|
亚洲国产美女精品久久久久∴
|
少妇无码一区二区三区免费
|
亚洲国产中文在线视频
|
精品国产免费观看久久久
|
国产亚洲蜜芽精品久久
|
亚洲综合区小说区激情区
|
日韩电影免费观看
|
亚洲精品天堂在线观看
|
亚洲第一永久AV网站久久精品男人的天堂AV
|
一级特黄录像免费播放中文版
|
亚洲国产无套无码av电影
|
永久免费在线观看视频
|
亚洲AV成人片色在线观看高潮
|
久久99国产亚洲高清观看首页
|
亚洲欧好州第一的日产suv
|
国产亚洲午夜精品
|
亚洲一区二区三区国产精品
|
久久精品免费观看国产
|
四虎亚洲精品高清在线观看
|
久久夜色精品国产亚洲av
|
h在线观看视频免费网站
|
免费在线观看自拍性爱视频
|