Skynet
posts - 165, comments - 198, trackbacks - 0, articles - 1
BlogJava
::
首頁
::
新隨筆
::
聯(lián)系
::
聚合
::
管理
struct 2 apps 學(xué)習(xí)(1)
Posted on 2008-04-21 17:51
G_G
閱讀(1213)
評論(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?處理類?
-->
??? <!--
相應(yīng)需要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
>
????
<!--
??默認(rèn)覆蓋
全部
路徑?
-->
????
<
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?跳轉(zhuǎn)?
-->
??? ???
<
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
?
????
//
默認(rèn)方法
11
?
????
public
?String?execute()?
throws
?Exception?{
12
?
????????
//
國際化方法使用?getText(?key?)
13
?
????????
//
?在url中體現(xiàn)->>?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-->
???????
<!--
?(關(guān)鍵: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(驗(yàn)證框架) 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(驗(yàn)證框架) end -->
????????
<!--
?jsp?封包 如:Missing.action就是Missiong.jsp
-->
????????
<
action?
name
="*"
?class
="example.ExampleSupport"
>
????????????
<
result
>
/example/{1}.jsp
</
result
>
????????
</
action
>
????????
<!--
?Add?actions?here?
-->
????
</
package
>
</
struts
>
新用戶注冊
刷新評論列表
只有注冊用戶
登錄
后才能發(fā)表評論。
網(wǎng)站導(dǎo)航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
相關(guān)文章:
struts2 ognl
struct 2 apps 學(xué)習(xí)(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上一些表達(dá)都不太好。
在此我盡量把我參考的原文給大家,
與大家學(xué)習(xí)。^_^
最近在維護(hù)www.tkk7.com\Skynet 腳本中
有什么技術(shù)問題不會,
我很愿意和大家討論!
多交流快成長
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關(guān)鍵字的使用
My連接
一個讀取Gmail郵件的簡單程序
bat 1%
eXtremeTable limit
java+web
jsp java javascrip 交互
JS函數(shù)集合大全
strut c:
Struts Menu
tree jsp
上手JFreeChart
關(guān)鍵筆記
根據(jù)name調(diào)用getName方法
用JAVA實(shí)現(xiàn)一個分頁類
搜索
最新評論
1.?re: 序列化和反序列化對象到 數(shù)據(jù)庫
qwe
--erwqe
2.?re: 部分高級查詢 sql 拼寫筆記 (mysql)
說實(shí)話,寫的的的確是差了那么一點(diǎn)點(diǎn)
--老衲用飄柔
3.?re: html 簡單 div 拖動
好。
--火星華人
4.?re: hibernate 多服務(wù)器數(shù)據(jù)同步問題(支持延遲同步)
評論內(nèi)容較長,點(diǎn)擊標(biāo)題查看
--張久強(qiáng)
5.?re: 數(shù)據(jù)庫表地址數(shù)據(jù)(中國地區(qū))
謝謝分享,收藏了!
--久久快樂鮮花
閱讀排行榜
1.?google svn 服務(wù)器使用(14266)
2.?mysql 權(quán)限控制筆記(11671)
3.?mysql 游標(biāo)使用(7120)
4.?強(qiáng)大的 ant scp 和 sshexec (6388)
5.?CGLib 學(xué)習(xí)(5784)
評論排行榜
1.?hibernate 多服務(wù)器數(shù)據(jù)同步問題(支持延遲同步)(12)
2.?部分高級查詢 sql 拼寫筆記 (mysql)(9)
3.?為在平安夜還在加班的程序員祝福!(8)
4.?原創(chuàng)小框架: 動態(tài)面向?qū)ο髷?shù)據(jù)庫操作(不要影射類哦)(6)
5.?自用小框架:DB工廠(6)
主站蜘蛛池模板:
亚洲精品一级无码中文字幕
|
亚洲人成人网站在线观看
|
亚洲国产aⅴ成人精品无吗
|
免费萌白酱国产一区二区
|
一个人免费视频观看在线www
|
亚洲欧洲日产国码在线观看
|
成人性生免费视频
|
爽爽爽爽爽爽爽成人免费观看
|
亚洲天堂电影在线观看
|
亚洲Av无码乱码在线znlu
|
久久久精品免费视频
|
亚洲AV无码一区二区三区久久精品
|
亚洲情综合五月天
|
成在人线AV无码免费
|
西西人体免费视频
|
亚洲AV日韩AV无码污污网站
|
亚洲国产成人久久精品影视
|
国产精品成人免费综合
|
99re6在线视频精品免费下载
|
亚洲麻豆精品果冻传媒
|
国产高清免费在线
|
99在线免费观看视频
|
免费人成网站永久
|
7777久久亚洲中文字幕
|
亚洲V无码一区二区三区四区观看 亚洲αv久久久噜噜噜噜噜
|
99久久久国产精品免费无卡顿
|
日本精品久久久久久久久免费
|
亚洲中文无码av永久
|
亚洲成av人影院
|
亚洲第一福利网站在线观看
|
台湾一级毛片永久免费
|
一级毛片在线免费看
|
人人鲁免费播放视频人人香蕉
|
中国亚洲呦女专区
|
亚洲春色另类小说
|
国产精品久久久亚洲
|
亚洲人妻av伦理
|
俄罗斯极品美女毛片免费播放
|
中文字幕无码成人免费视频
|
久久伊人免费视频
|
99久久国产精品免费一区二区
|