Mybatis+struts2+html (JSTL) +css

Source: Internet
Author: User
Tags cdata

from October 8 to today 23rd, came to work has been half a month, this is my life in the real sense of a step into the society, with their 20 years of perseverance and efforts to achieve the first steps of life, to tell the truth, feel that they really are a lucky dog, as if it is in favor of me, all things are so smooth, Let me have no reason not to cherish now all, thank you teacher, time and again to meet my request, this half month I received the goods from the human life, team management, or technical aspects are many, so every night sleep will be a lie, because a open eyes will be busy day, but really really very substantial, Let me start with the technical gains.

The most recent time has been in contact with the backstage, I say? The biggest feeling is that in school practice on my influence is beyond doubt, plus later to participate in java3.1 and 4.0,s let me be able to accept the present frame relatively quickly, say I recently made a module: invite management.

Requirements: Our company is a wealth management company, everyone knows the invitation code, if one person invited another person will be invited to enter the invitation code when registering, such as:

That later, before the upgrade is not to the inviter and invited people to associate, there is only one entity, then someone to call the customer service said I have already entered the invitation code, why did not show, then why the inviter would like to invite someone else to enter the invitation code, because if the invited people to invest, Then invite people will have a commission, so demand is so produced, we need to add the inviter and invited people's relationship, and can be disabled, but can not be modified, because if can be modified, the people who operate the background is rich, he can casually change the invitation to himself, so this is not possible, but also need to be able to export, In fact, it's quite simple. Let's talk about the query function first:

MyBatis:

Here we need to write the query statement, this statement is really huge, we need to identify the inviter and invitees from the Customer table, and then go to the investment form to find out the amount of the invitee investment, in the inviter and invitees of the relationship table to find out the relationship between the inviter and the invitee:

T_cust_user: Customer table; t_loan_bid: Investment form; T_cust_user_invite: Invitation Form

Here's a look at my SQL statement :

<span style= "font-family:arial, Helvetica, Sans-serif;" ><sqlmap namespace= "<strong>CustomerUserInvite</strong>" ></SPAN> 
<select id= "<strong>queryInviterList</strong>" parameterclass= "map" resultclass= "Java.util.HashMap "><! [Cdata[select T8.*,t9.] NAME "from (select t7.* from (selectt5.user_id,t5. User_name,t5. Invite_user_id,t6. User_name as INVITE_USER_NAME,T5. Bid_amount,t5.operator_,t5. Status,t5. Bid_status,to_char (T6. Create_time, ' Yyyy-mm-dd hh24:mi:ss ') create_time,t5. " ID "from (SELECTT3.USER_ID,T4. User_name,t3. Invite_user_id,t3. Bid_amount,t3.operator_,t3. Bid_status,t3. Status,t3. " ID "from (selectt1.user_id,t1. Invite_user_id,t1. Operator_,t2. Bid_amount,t2. Bid_status,t1. " ID ", T1. Statusfromt_cust_user_invite t1left JOIN t_loan_bid T2 on T1. invite_user_id = t2. USER_ID) t3left JOIN t_cust_user T4 on T3. user_id = t4.id) t5left JOIN t_cust_user T6 on T5. invite_user_id = T6. ID) T7where 1=1) T8 left JOIN T_user_user T9 on t8.operator_=t9.id]]><isnotempty prepend= "" property= "searchContent ">where (T8. User_name like '% $searchContent $% ' OR T8. Invite_user_name like '% $searchContent $% ') </isnotempty><! [Cdata[order by T8. STATUS Desc,t8. Create_time desc]]></select></sqlmap>
Layer D:

public class Inviterdao extends abstractbasedao<customeruserinvitebean> {public Inviterdao (sqlmapclient sqlMap) {super (SQLMAP);} The namespace in the corresponding XML @overridepublic String GetNamespace () {return "Customeruserinvite";} The corresponding data table @overridepublic String Gettablename () {return "T_cust_user_invite";} /** * Enquiry All-wang Dan *  * @param parammap * @return * @throws Exception */public datawrap pagequery (Map parammap) throws Excep tion {return (datawrap) dataaccessor.query (GetNamespace () + ".<strong>queryinviterlist</strong>", Parammap, Rs_type. PAGED);}}
Service:

/** * Paging Query All-Wang Dan-October 14, 2015 16:43:38 *  * @param parammap * @return * @throws Exception */public datawrap pagingquery (Ma P InputMap) throws Exception {return new Inviterdao (null). Pagequery (InputMap);}
controller here to notice:

instead of just looking for the controller, we put it in the config file and check it by name, using struts:

<!--inviter management--><service name= "Inviterservice" class= " Com.voiinnov.puhuilicai.customer.controller.InviterController "></service>
Here's a look at the controller:

public class Invitercontroller extends Aservice {private static Logger Logger = Logger.getlogger (invitercontroller.class );p rivate Inviterservice inviterservice = new Inviterservice (), @SuppressWarnings ({"Unchecked", "rawtypes"}) public void Listinviter (Context context) {List errorlist = context.errlist;//is used to store the returned results, and is returned to the interface map Outputmap with JSON = inviterservice.outputmap;try {Datawrap datawarp = this.inviterService.pagingQuery (CONTEXT.CONTEXTMAP);// Result set Outputmap.put ("DW", Datawarp), Outputmap.put ("Searchcontent", Context.contextMap.get ("searchcontent"));} catch (Exception e) {e.printstacktrace (); Errorlist.add ("System error, contact your system administrator! "); Logger.error (This.getclass (). GetName () +": ", e); E.printstacktrace (); if (Context.errList.isEmpty ()) {Output.jspoutput (Outputmap, Context, "/puhuilicai/customer/inviterlist.jsp");} else {Outputmap.put ("errlist", Context.errlist), Output.jspoutput (Outputmap, Context, "/error.jsp");}}
in the JSP:
<body onload= "setaction (); ><form name= "Form1" Id= "Form1" <strong> action= ". /servlet/defaultdispatcher "</strong>method=" POST "><input name=" __action "value=" <strong> Inviterservice.listinviter</strong> "type=" hidden "/> <input name=" statusshow "value=" ${statusShow} " Type= "hidden"/><!--Head Start--><div id= "Fixedlayer" ><div class= "main" ><div class= "Main_c main_ BG "><div class=" Main_nav "><div class=" nav_pic "><a href=" javascript:void (0) "title=" added "onclick=" Initinviter () "></a> <a href=" Javascript:void (0); "title=" Export "onclick=" Exportinviter () "></a><ul style=" float:right; margin-right:5px; Text-align:left; " ><li><a href= "javascript:void (0)" title= "Enable" onclick= "UpdateStatus (0)" >   start    </a></li><li><a href= "JavascrIpt:void (0) "title=" Deactivate "onclick=" UpdateStatus ( -2) ">   Forbidden    </a></li></ul> </div></div></div></div></div><!--head End--><!-fuzzy query starts--><div class= " Margintop40 "></div><div class=" main "><div class=" Main_c main_bg "><!--Adaptive width-start--> <div class= "Table_scroll" ><table width= "100%" border= "0" cellspacing= "0" cellpadding= "0" ><tr>< TD align= "Center" valign= "top" ><table width= "100%" border= "0" align= "center" cellpadding= "0" cellspacing= "0" class= "><tr align=" center "valign=" middle "><td height=" "align=" left "valign=" Middle "class=" Table_ TITLE_TD_BG "><div style=" float:left; line-height:30px; " ><span class= "margin_left10 font_white" ><strong></strong></span></div> <%@ Include file= "/commons/pagecontrol.jsp"%><!--search and sort-start--><div style= "float:right; line-height:30px; width:450px; " ><div class= "Tsearch-panel-fields "style=" MARGIN-TOP:6PX; " ><label for= "Searchcontent" > Invitees, invitees </label> <inputname= "searchcontent" id= "Searchcontent" type= "Text" class= "span3" value= "${searchcontent}"/></div><input type= "image" onclick= "Dosearch ();" src= "${ctx}/commons/images/system/btn_search.png" style= "width:50px; height:23px; margin-top:6px; margin-left:5px;/></div> <!--search and sort-end--></tr></table></td></tr></ table></div><!--query Form--><table width= "100%" border= "1" align= "center" cellpadding= "0" cellspacing= "0" class= "table_style table2" ><tr><th style= "Text-align:center" class= "TABLE_TH_BG" > Serial number </td> <th style= "Text-align:center", "class=" TABLE_TH_BG "> Inviter </th><th style=" text-align:center; "class=" TABLE_TH_BG "> Invited </th><th style=" Text-align:center "class=" TABLE_TH_BG "> Registration time </th><th Style= "Text-align:center;" class= "TABLE_TH_BG" > Operator &LT;/TH&Gt;<th style= "text-align:center;" class= "TABLE_TH_BG" > Investment amount </th><th style= "text-align:center;" class= "TABLE_TH_BG" > Investment status </th><th style= "Text-align:center; class=" TABLE_TH_BG "> Status </th></tr ><!--Traverse Query Results--><c:foreach items= "${dw.rs}" var= "lists" varstatus= "status" ><tr id= "${lists.id}" User_id= "${lists. USER_ID} "onclick=" Changetrcolor (this); "style=" cursor:pointer; " <c:if test= "${status.count% 2 = = 0}" >bgcolor= "#F5F5F5" </c:if>><td style= "text-align:center;" >${status.count + dw.pagesize * (dw.currentpage-1)}</td><td height= ">${lists". USER_NAME}&LT;/TD&GT;&LT;TD height= ">${lists". INVITE_USER_NAME}&LT;/TD&GT;&LT;TD height= "26px" >${lists. CREATE_TIME}&LT;/TD&GT;&LT;TD height= ">${lists.name}</td><td height=" ><c:choose><c : When test= "${empty lists. Bid_amount} ">0</c:when><c:otherwise>${lists. Bid_amount}</c:otherwise></c:choose></td> &LT;TD height= "><c:choose><c:when test=" ${lists. Bid_status eq-1} "> Pending payment </c:when><c:when test=" ${lists. Bid_status eq 1} "> Investment in </c:when><c:when test=" ${lists. Bid_status eq 2} "> Repayment in </c:when><c:when test=" ${lists. Bid_status eq 5} "> Debt transfer </c:when><c:when test=" ${empty lists. Bid_status} "> not invested </c:when><c:otherwise> unknown &LT;/C:OTHERWISE&GT;&LT;/C:CHOOSE&GT;&LT;/TD&GT;&LT;TD ><c:choose><c:when test= "${lists. STATUS eq 0} "> Enable </c:when><c:otherwise> Disable &LT;/C:OTHERWISE&GT;&LT;/C:CHOOSE&GT;&LT;/TD&GT;&LT;/TR ></c:foreach></table><%@ include file= "/commons/pagecontrolbottom.jsp"%></div></ div><!--content ends--><div class= "Space" ></div></form></body>
Here's how it works:


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Mybatis+struts2+html (JSTL) +css

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.