struts+spring實(shí)現(xiàn)的登陸實(shí)例源碼(4)_JSP教程
教程Tag:暫無(wú)Tag,歡迎添加,賺取U幣!
推薦:淺談Tomcat常用調(diào)試技巧大多數(shù)用戶安裝好Tomcat之后就開(kāi)始正式運(yùn)行,很少對(duì)服務(wù)器進(jìn)行全面調(diào)優(yōu)。這樣做的結(jié)果是如果并發(fā)量小,系統(tǒng)可能不會(huì)出問(wèn)題,但是并發(fā)量大時(shí),系統(tǒng)反應(yīng)速度迅速下降,但由于不了解原因,因此可能還在自己的應(yīng)用程序中尋找問(wèn)題~~,本文就Tomcat4為基礎(chǔ)向大家介
5、根據(jù)前一步的代碼,進(jìn)行配置文件的編寫(xiě)(struts-config.xml和applicationContext.xml)
選擇Welcome_SS工程下的WebRoot -> WEB-INF -> struts-config.xml
輸入下面代碼:
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">
3
4 <struts-config>
5 <data-sources />
6 <form-beans >
7 <form-bean name="loginForm" type="com.yourcompany.struts.form.LoginForm" />
8 </form-beans>
9
10 <global-exceptions />
11 <global-forwards />
12 <action-mappings >
13 <action
14 attribute="loginForm"
15 input="/login.jsp"
16 name="loginForm"
17 path="/login"
18 scope="request"
19 type="org.springframework.web.struts.DelegatingActionProxy">
20 <forward name="success" path="/success.jsp" />
21 <forward name="reinput_blank" path="/reinput_blank.jsp"/>
22 <forward name="reinput_error" path="/reinput_error.jsp"/>
23 </action>
24
25 </action-mappings>
26
27 <message-resources parameter="com.yourcompany.struts.ApplicationResources" />
28
29 <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
30 <set-property property="contextConfigLocation" value="/WEB-INF/classes/applicationContext.xml" />
31 </plug-in>
32
33 </struts-config>
34
35
選擇Welcome_SS工程下的src -> applicationContext.xml
輸入下面代碼:
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
3 <beans>
4 <bean name="/login" class="com.yourcompany.struts.action.LoginAction">
5 <property name="message">
6 <value>Welcome_</value>
7 </property>
8 </bean>
9 </beans>
10
6、Web Service(這里即Tomcat)布署及啟動(dòng)
(全面的可以參照我的另一篇隨筆:Myeclipse中Tomcat的兩種布署方式)
a.在apache-tomcat-5.5.20"conf下,找到server.xml,打開(kāi),在</Host>前面添加一句
<Context path="/wess" debug="0" docBase="C:\Documents and Settings\tt\workspace\Welcome_SS\WebRoot" reloadable="true"></Context>
注:C:\Documents and Settings\tt\workspace\Welcome_SS是該工程的存儲(chǔ)路徑。
b.在Myeclipse中的工具欄上找到一個(gè)像機(jī)箱似形狀的按鈕,點(diǎn)擊,則打開(kāi)服務(wù)器Tomcat.
7、運(yùn)行
在IE 瀏覽器里輸入http://localhost:8080/wess,即可運(yùn)行!成功登陸的條件是用戶名和密碼都為success的時(shí)候。
分享:Jsp+struts分頁(yè)顯示源碼主要有三個(gè)文件:show.jsp、ShowAction.java、PageInformation.java 環(huán)境是:JDK1.6+mysql5.0+jboss4.0+struts2.0.11 還需完善的地方:如果沒(méi)有前一頁(yè)、后一頁(yè),直接把這個(gè)鏈接在頁(yè)面上屏蔽掉 因?yàn)椴幌朐贏ction里面有太多的鏈接數(shù)據(jù)庫(kù)的代碼,所以另外搞了一個(gè)
相關(guān)JSP教程:
- jsp response.sendRedirect不跳轉(zhuǎn)的原因分析及解決
- JSP指令元素(page指令/include指令/taglib指令)復(fù)習(xí)整理
- JSP腳本元素和注釋復(fù)習(xí)總結(jié)示例
- JSP FusionCharts Free顯示圖表 具體實(shí)現(xiàn)
- 網(wǎng)頁(yè)模板:關(guān)于jsp頁(yè)面使用jstl的異常分析
- JSP頁(yè)面中文傳遞參數(shù)使用escape編碼
- 基于jsp:included的使用與jsp:param亂碼的解決方法
- Java Web項(xiàng)目中連接Access數(shù)據(jù)庫(kù)的配置方法
- JDBC連接Access數(shù)據(jù)庫(kù)的幾種方式介紹
- 網(wǎng)站圖片路徑的問(wèn)題:絕對(duì)路徑/虛擬路徑
- (jsp/html)網(wǎng)頁(yè)上嵌入播放器(常用播放器代碼整理)
- jsp下顯示中文文件名及絕對(duì)路徑下的圖片解決方法
- 相關(guān)鏈接:
- 教程說(shuō)明:
JSP教程-struts+spring實(shí)現(xiàn)的登陸實(shí)例源碼(4)
。