Struts + Hibernate + Oracle Patement

xiaoxiao2021-03-04  55

STRUTS HIBERNATE ORACLE tab 9cbs lifetragedy mainly selected from: message.jspMessageFormMessageActionPlayer.hbm.xmlstruts-config.xmlMeisaiBean.java achieved: look at the database structure: CREATE TABLE player (PLAYER_ID VARCHAR (32) PRIMARY KEY, TEAM VARCHAR (3 ), displayName VARCHAR (100), LAST_NAME VARCHAR (100), mIDDLE_NAME VARCHAR (100), STATUS VARCHAR (32), POS VARCHAR (1), PPG INTEGER default 25); INSERT INTO player (pLAYER_ID, TEAM, displayName, LAST_NAME, Middle_name, status, pos) Values ​​('2113999,' Dal ',' Dirk ', NULL,' ', NULL,' F '); Insert Into Player (Player_ID, Team, DisplayName, Last_name, Middle_name, Status, POS) VALUES ('30361', 'IND', 'RON', 'ARTEST', '', 'A', 'G'); INSERT INTO Player (Player_ID, Team, DisplayName, Last_Name, Middle_Name, Status, POS) VALUES (STATUS, POS) '30273', 'orl', 'TRACY', 'MCGRADY', '', 'A', 'F'); INSERT INTO Player (Player_ID, Team, DisplayName, Last_name, Middle_name, Status, POS) Values ​​('30190 ',' LAL ',' Kobe ',' Bryant ',' ',' A ',' g '); Insert Into Player (Player_ID, Team , DisplayName, Last_name, Middle_Name, Status, POS, Values ​​('30328', 'Sea', 'Rashard', 'Lewis',', 'A', 'G'); Insert Into Player (Player_ID, Team, DisplayName , Last_name, Middle_Name, Status, POS) VALUES ('30197', 'NJN', 'Kerry', 'Kittles',', 'A', 'g'); Insert Into Player (Player_ID, Team, DisplayName, Last_name , Middle_Name, Status, POS) Values ​​('30341', 'Hou', 'Steve', 'Francis', '', 'A', 'G');

INSERT INTO Player (Player_ID, Team, DisplayName, Last_name, Middle_Name, Status, POS) Values ​​('30146', 'min', 'Kevin', 'Garnett', ',' A ',' F '); Insert Into Player (Player_ID, Team, DisplayName, Last_name, Middle_name, Status, POS) Values ​​('2113993', 'BOS', 'Paul', 'Pierce', ',' A ',' G '); Insert Into Player Player_ID, Team, DisplayName, Last_name, Middle_Name, Status, POS) VALUES ('30050', 'NJN', 'Jason ",' KIDD ',' ',' A ',' G '); Insert Into Player (Player_ID, TEAM, DISPLAYNAME, LAST_NAME, MIDDLE_NAME, STATUS, POS VALUES ('30215', 'ATL', 'Shareef', 'Abdur-Rahim', '', 'I', 'F'); Insert Into Player (Player_ID, Team, DisplayName, Last_name, Middle_Name, Status, POS, VALUES ('1861922', 'orl', 'Mike', 'Miller', ',' I ',' F '); Insert Into Player (Player_ID, Team, DisplayName, Last_name, Middle_Name, Status, POS) VALUES ('30144', 'ATL', 'Glenn', 'Robinson', '', 'A', 'F'); Insert Into Player (Player_ID, Team, DisplayName, Last_name, middle_name, status, pos) Values ​​('2019703', 'GSW', 'Gilbert', 'Arenas', '', 'A', 'G'); Insert Into Player (Player_ID, Team, DisplayName, Last_name, Middl E_NAME, STATUS, POS) VALUES ('2028505', 'uth', 'andrei', 'Kirilenko', '', 'I', 'F'); Insert Into Player (Player_ID, Team, DisplayName, Last_name, Middle_Name, Status, POS) VALUES ('30382', 'pho', 'Shawn', 'Marion', '', 'A', 'F');

INSERT INTO Player (Player_ID, Team, DisplayName, Last_name, Middle_name, Status, POS) Values ​​('29941', 'Sea', 'Brent', 'Barry', ',' A ',' g '); Insert Into Player (Player_ID, Team, DisplayName, Last_name, Middle_Name, Status, POS) Values ​​('2114000', 'DAL', 'Michael', 'Finley', '', 'A', 'G'); Insert Into Player Player_ID, Team, DisplayName, Last_name, Middle_Name, Status, POS, 'Antoine', 'Walker', '', 'A', 'F'); Insert Into Player (Player_ID, Team, DisplayName, Last_name, Middle_Name, Status, POS, VALUES ('30234', 'Sac', 'Bobby', 'Jackson', ',' A ',' G '); Insert Into Player (Player_ID, Team, DisplayName, Last_name, Middle_Name, Status, POS, VALUES ('29968', 'Was', 'Jerry', 'Stackhouse', '', 'A', 'G'); Insert Into Player (Player_ID, Team, DisplayName, Last_name, middle_name, status, pos) Values ​​('29944', 'Sac', 'Doug', 'Christie', '', 'I', 'G'); Insert Into Player (Player_ID, Team, DisplayName, Last_name, Middle_name, status, pos) Values ​​('30095', 'Chi', 'Donyll', 'Marshall', '', 'A', 'F'); Insert Into Player (Player_ID, Team, DisplayName, Last_name, Middle, Middle Le_name, status, pos) Values ​​('2028865', 'ATL', 'IRA', 'NEWBLE', '', 'A', 'F'); INSERT INTO Player (Player_ID, Team, DisplayName, Last_name, Middle_Name, Status, POS) VALUES ('30029', 'SEA', 'Gary', 'Payton', '', 'A', 'G');

Insert Into Player (Player_ID, Team, DisplayName, Last_name, Middle_Name, Status, POS) Values ​​('30141', 'Tor', 'Voshon', 'LENARD', ',' A ',' G '); Insert Into Player (Player_ID, Team, DisplayName, Last_name, Middle_Name, Status, POS) VALUES ('30020', 'Mil', 'Toni', 'Kukoc', ',' A ',' F '); Insert Into Player Player_ID, TEAM, DISPLAYNAME, LAST_NAME, MIDDLE_NAME, STATUS, POS, ',' PJ ',' Brown ',' ',' A ',' F '); Insert Into Player (Player_ID, Team, DisplayName, Last_name, Middle_name, Status, POS, Values ​​('30125', 'MIA', 'EDDIE', 'Jones',', 'A', 'g'); Insert Into Player (Player_ID, Team, DisplayName, Last_name, Middle_Name, Status, POS) VALUES ('30359,' ATL ',' Jason ", 'Terry', ',' A ',' g '); Insert Into Player (Player_ID, Team, DisplayName, Last_name, middle_name, status, pos) Values ​​('30291', 'uth', 'matt', 'Harpring', '', 'A', 'f'); Insert Into Player (Player_ID, Team, DisplayName, Last_name, Middle_name, status, pos) Values ​​('30228', 'mil', 'ray', 'allen', ',' a ',' g '); Insert Into Player (Player_ID, Team, DisplayName, Last_name, Middle_name, STATUS, POS) VA Lues ('2028503', 'SEA', 'VLADIMIR', 'RADMANOVIC', '', 'A', 'F'); the corresponding Player.hbm.xml is as follows:

Http://hibernate.sourceForge.Net/Hibernate-mapping-2.0.dtd"> "Hibernate-mapping" !-- Test Player -> now look MeisaiBean.javapackage com.ecc.util; import java.io.Serializable; public class MeisaiBean implements Serializable {public MeisaiBean () {} Public String Label_1 = ""; PUBLIC VOID SetLabel_1 (String Str) {this.Label_1 = Str;} P Ublic string getLabel_1 () {return this.label_1;} public string label_2 = ""; public void setLabel_2 (String str) {this.label_2 = Str;} public string getLabel_2 () {return this.label_2;

} Public String label_3 = ""; public void setLabel_3 (String str) {this.label_3 = str;} public String getLabel_3 () {return this.label_3;} public String label_4 = ""; public void setLabel_4 (String str) { this.label_4 = str;} public String getLabel_4 () {return this.label_4;} public String label_5 = ""; public void setLabel_5 (String str) {this.label_5 = str;} public String getLabel_5 () {return this. label_5;} public String label_6 = ""; public void setLabel_6 (String str) {this.label_6 = str;} public String getLabel_6 () {return this.label_6;} public String label_7 = ""; public void setLabel_7 (String str ) {this.label_7 = str;} public String getLabel_7 () {return this.label_7;} public String label_8 = ""; public void setLabel_8 (String str) {this.label_8 = str;} public String getLabel_8 () {return THISLIC STRING LABEL_9 = ""; PUBLIC VOID SETLABEL_9 (String Str) {this.label_9 = Str;} PUBL ic String getLabel_9 () {return this.label_9;} public String label_10 = ""; public void setLabel_10 (String str) {this.label_10 = str;} public String getLabel_10 () {return this.label_10;} public String label_11 = ""; public void setLabel_11 (String str) {this.label_11 = str;} public String getLabel_11 () {return this.label_11;} public String label_12 = ""; public void setLabel_12 (String str) {this.label_12 = str } Public string getLabel_12 () {return this.label_12;} public string label_13 = ""

public void setLabel_13 (String str) {this.label_13 = str;} public String getLabel_13 () {return this.label_13;} public String label_14 = ""; public void setLabel_14 (String str) {this.label_14 = str;} public String getLabel_14 () {return this.label_14;} public String label_15 = ""; public void setLabel_15 (String str) {this.label_15 = str;} public String getLabel_15 () {return this.label_15;} public String label_16 = " "; public void setLabel_16 (String str) {this.label_16 = str;} public String getLabel_16 () {return this.label_16;} public String label_17 =" "; public void setLabel_17 (String str) {this.label_17 = str; } public String getLabel_17 () {return this.label_17;} public String label_18 = ""; public void setLabel_18 (String str) {this.label_18 = str;} public String getLabel_18 () {return this.label_18;} public String label_19 = ""; Public void setlabel_19 (string str) {this.label_19 = Str;} Publ ic String getLabel_19 () {return this.label_19;} public String label_20 = ""; public void setLabel_20 (String str) {this.label_20 = str;} public String getLabel_20 () {return this.label_20;} public String label_21 = ""; public void setLabel_21 (String str) {this.label_21 = str;} public String getLabel_21 () {return this.label_21;}} MessageForm.java://Created by MyEclipse Struts // XSL source (default): platform : /plugin/com.genuitec.eclipse.cross.EASYSTRUTS.ECLIPSE_3.8.2/XSLT/JAVACLASS.XSLPACKAGE.ACC.STRUTS.MPORT Org.Apache.Struts.Action.ActionForm;

import javax.servlet.http.HttpServletRequest; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionMapping; import java.util *;. / ** * MyEclipse Struts * Creation date: 01-06-2005 * * XDoclet definition: * @struts: form name = "testRegistForm" * / public class MessageForm extends ActionForm {public MessageForm () {} private String label1 = ""; / ** * @return * / public string getLabel1 () {return Label1;} / ** * @Param string * / public void setLabel1 (String string) {label1 = string;} private vector meisai = new vector (); public void setMeisai (Vector meisai) {this.meisai = meisai;} public Vector getMeisai () {return meisai;} private int currentPage = 0; / ** * @return * / public int getCurrentPage () {return currentPage;} / * * @Param i * / public void setCurrentPage (INT i) {currentpage = i;} private int totalpage = 0; / ** * @return * / public int gettotalpage () {Return Totalpage;} / ** * @Param i * / public c void setTotalPage (int i) {totalPage = i;}} MessageAction.java://Created by MyEclipse Struts // XSL source (default): platform: /plugin/com.genuitec.eclipse.cross.easystruts.eclipse_3.8.2 /xslt/JavaClass.xslpackage com.ecc.struts.message.action; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action. Action; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.SessionActionMapping; import org.apache . Struts.Action.Actionerror;

Import org.Apache.struts.Action.ActionerRuts.Mport com.ecc.struts.MPort com.ecc.util. *; import java.security. *; import com.ecc.util.security.password Import com.ecist. *; import com.ecc.hibernate.db. *; import net.sf.hibernate. *; import net.sf.hibernate.cfg. *; import com.ecc. Import com.ecc.hibernate.hbm. *; import java.util. *; public class message ------------------------------------- Instance Variables / / --------- ------------------------------------------------ Methods / ** * Method execute * @param mapping * @param form * @param request * @param response * @return ActionForward * / private void setPage (ActionForm form, int currentPage) {Transaction tx = null; Session session = null; int totalCount = 0; String playerid = ""; String team = ""; String displayname = ""; int firstIndex = 0; int itemsInPerPage = 10; try {MessageForm messageForm = (MessageForm) form; session = HbUnit.getSession (); tx = session.begintransaction (); currentpage = messageForm.getCurrentPage (); if (currentPage <= 0) {messageForm.setCurrentPage (1); firstIndex = 0;} else {firstIndex = currentPage * itemsInPerPage-itemsInPerPage;} String sql = "select player from Player as player"; Query query = session.createQuery (sql); query.setFirstResult (firstIndex); query.setMaxResults (itemsInPerPage); Iterator it = query.iterate (); Vector meisaiList = new Vector (); while (it.hasNext ()) {Player player = (Player) it.next (); playerid = StrHandle.replaNull (player.getPlayerId ()); team = StrHandle.replaNull (player.getTeam ()); displayname = StrHandle.replaNull (player.getDisplayName ()); Meisaibean meisai =

new MeisaiBean (); meisai.setLabel_1 (playerid); meisai.setLabel_2 (team); meisai.setLabel_3 (displayname); meisaiList.add (meisai);} messageForm.setMeisai (meisaiList); tx.commit ();} catch ( Exception ex) {TRY {tx.rollback ();} catch (exception eex) {} system.out.println (ex); ex.printstacktrace ();} finally {Try {hbunit.closesession ();} catch (Exception EX) {}}} private int getRecordsize () {Transaction TX = NULL; session session = null; int totalcount = 0; try {session = hbunit.getations (); tx = session.begintransaction (); totalcount = ((Integer) "Session.Ikeer"). next ()) .intValue (); tx.commit (); return totalcount;} catCh (Exception ex) {TRY {TX.ROLLBACK ();} Catch (Exception Eex) {} system.out.println (ex); ex.printstacktrace (); return -1;} finally {Try {hbunit.closesis ();} catch (exception ex) {}}}} public actionforward execute form (ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {MessageForm messageForm = (MessageForm); String target = ""; int size = 0; int perItemsPage = 10; i nt modItems = 0; int totalPages = 0; int currentPage = 0; try {currentPage = messageForm.getCurrentPage (); size = getRecordSize (); if (size <= 0) {target = "noitemfound";} else {totalPages = Size / peritemspage; moditems = size% peritemspage; if (MODITEMS> 0) Totalpages = 1; System.out.Println ("Record Size:" size); System.out.Println ("Total Page: TotalPages); Messageform.SettotalPage (Totalpages); SESTEM.OUT.PRINTLN ("Total Page: Totalpages); target =" success ";}} catch (exception ex) {system.out.println (EX ); ex.PrintStackTrace ();} return (maping.findforward (target));}} message.jsp as follows: <% @

Page language = "java"%> <% @ Page ContentType = "text / html; charset = GB2312"%> <% @ Taglib URI = "/ Web-inf / struts-html.tld" prefix = "html"%> <% @ Taglib Uri = "/ Web-inf / struts-bean.tld" prefix = "bean"%> <% @ Taglib URI = "/ Web-inf / struts-logic.tld" prefix = "logic"%> jsp for testregistform form </ title> <style type = text / css> font-size: 9pt {} a {color: # 000000; text-decoration: none} a: hover {text -Decoration: underline} .bt {border-top-width: 0px; border-left-width: 0px; font-size: 9pt; border-bottom-width: 0px; width: 50px; cursor: hand; height: 16px; Background-color: # 808080; border-right-width: 0px} .tx1 {border-right: black 1px ridge; border-top: black 1px ridge; font-size: 9pt; border-left: black 1px ridge; width: 60pt; COLOR: # 000000; BORDER-BOTTOM: # 000000 1px ridge; HEIGHT: 20px} </ STYLE> </ head> <Script Language = "JavaScript"> function gotoNext () {var currentPage = parseInt (MessageForm.currentPage. Value); var totalpage = parseint (messageform.totalpage.value); currentpage = currentpage 1; if (Curre ntPage> totalPage) {currentPage = totalPage;} var url = "message.do?currentPage =" currentPage; alert (url); document.location = url;} function gotoPrev () {var currentPage = parseInt (MessageForm.currentPage. value); var totalPage = parseInt (MessageForm.totalPage.value); if (currentPage <= 0) {currentPage = 0;} else {currentPage = currentPage-1;} var url = "message.do?currentPage =" currentPage Alert (URL); Document.Location = URL;} Function Gototop () {var URL = "</p> <p>Message.do?currentpage=1";lert (url );document.location=URL_ }Function gotolast () {var Totalpage = PARSEINT (MSSAGEFORM.TOTALPAGE.VALUE); var URL = "message.do?currentpage =" TotalPage; Alert (URL); Document.Location = URL;} </ script> <body> <html: form name = "messageform" action = "/ message.do" type = "com.ec.struts.Message.FORMBEAN .Messageform "scope =" request "> <html: text property =" currentpage "/> </br> <html: text proteth =" totalpage "/> </br> </ html: form> <Table> <TR > <TD> <input value = "TOP" type = "button" οnclick = "gototop ();"> <TD> <input value = "οnclick =" button "οnclick =" gotoprev (); "> <> < TD> <input value = "NEXT" TYPE = "button" οnclick = "gotonext ();"> <TD> <input value = "type =" button "οnclick =" gotolast (); "> </ tr > </ table> <table border = '1'> <logic: present name = "messageform" scope = "request"> <logic: Itereate ID = "meisailist" name = "messageform" proty = "meisai" scope = " Request "> <tr> <td> <bean: Write name =" meisailist "Property =" label_1 "/> </ td> <td> <bean: write name =" meisailist "property =" label_2 "/> </ TD> <TD> <bean: write name = "meisailist" property = "label_3" /> </ td> </ tr> </ logic: Itereate> </ logic: present> </ table></p> <p></ body> </ html> BLOG:</p> <p>http://blog.9cbs.net/lifetrageedy/</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-31645.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="31645" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.050</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'OBe28uN_2BGBWtAn1JjoQ_2F5A8RqnbNi00aeGh86_2FgIU5hYGBopVYx6N7_2FpvYzCA8cIFwRPIXpyNxx6J5EGBy1sQA_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>