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
公告
由于時(shí)間問題,
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連接
一個(gè)讀取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)一個(gè)分頁類
搜索
最新評論
1.?re: 序列化和反序列化對象到 數(shù)據(jù)庫
qwe
--erwqe
2.?re: 部分高級查詢 sql 拼寫筆記 (mysql)
說實(shí)話,寫的的的確是差了那么一點(diǎn)點(diǎn)
--老衲用飄柔
3.?re: html 簡單 div 拖動(dòng)
好。
--火星華人
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)限控制筆記(11670)
3.?mysql 游標(biāo)使用(7120)
4.?強(qiáng)大的 ant scp 和 sshexec (6388)
5.?CGLib 學(xué)習(xí)(5783)
評論排行榜
1.?hibernate 多服務(wù)器數(shù)據(jù)同步問題(支持延遲同步)(12)
2.?部分高級查詢 sql 拼寫筆記 (mysql)(9)
3.?為在平安夜還在加班的程序員祝福!(8)
4.?原創(chuàng)小框架: 動(dòng)態(tài)面向?qū)ο髷?shù)據(jù)庫操作(不要影射類哦)(6)
5.?自用小框架:DB工廠(6)
主站蜘蛛池模板:
亚洲精品乱码久久久久久V
|
国产在线精品观看免费观看
|
久久夜色精品国产亚洲
|
亚洲人成色777777老人头
|
爱情岛论坛亚洲品质自拍视频网站
|
久久精品电影免费动漫
|
亚洲国产成人久久综合碰
|
亚洲人成网77777亚洲色
|
亚洲爆乳少妇无码激情
|
免费能直接在线观看黄的视频
|
在线视频免费国产成人
|
久久亚洲AV永久无码精品
|
亚洲精品美女久久7777777
|
亚洲精品免费在线
|
亚洲色成人WWW永久网站
|
在线亚洲精品视频
|
精品成人免费自拍视频
|
91黑丝国产线观看免费
|
国产亚洲福利一区二区免费看
|
亚洲欧洲精品国产区
|
男女午夜24式免费视频
|
中文字幕亚洲乱码熟女一区二区
|
国产美女在线精品免费观看
|
亚洲AV无码一区二区乱子伦
|
亚洲第一男人天堂
|
91香蕉国产线在线观看免费
|
国产精品亚洲成在人线
|
xxxxx做受大片视频免费
|
久久午夜夜伦鲁鲁片免费无码影视
|
亚洲日韩国产精品第一页一区
|
免费看黄网站在线看
|
国产免费看插插插视频
|
亚洲色偷偷综合亚洲av78
|
国产免费毛不卡片
|
亚洲第一页中文字幕
|
最近中文字幕mv免费高清在线
|
亚洲av日韩av无码黑人
|
特级毛片免费观看视频
|
国产极品粉嫩泬免费观看
|
亚洲乱妇熟女爽到高潮的片
|
18禁超污无遮挡无码免费网站国产
|