Java & struts 2 Study Notes

Source: Internet
Author: User
ArticleDirectory
    • Java syntax
    • Struts
Java syntax
 
// Example of a wildcard, call // bar OBJ = new bar <videoinfo> (); // arraylist <videoinfo> List = obj. render (Service, album. GETID (); Class bar <t> {public arraylist <t> render (Service, int albumid) {albuminfoservice videolist_service = (albuminfoservice) service. getserviceincache (); Map <string, Object> videolist = videolist_service.findvideosbyalbum (albumid, 0, 10 ). getvideos (); arraylist <t> List = (arraylist <t>) videolist. get ("Results"); return list; // long totalcount = (long) videolist. get ("totalcount ");}}

Traverse map:

 
For (Java. util. Map. Entry mapentry: responsedata. entryset () {key = mapentry. getkey (); Value value = mapentry. getvalue ();}
Reflection requires java. Lang. Reflect .*
Class article extends baseservice <articleinfo> {public void F () {class clazz = This. getclass (); method [] Methods = clazz. getmethods (); For (method: Methods) {If (method. getname (). equals ("findbyid") {system. out. println ("---"); system. out. print (method. getreturntype (). getname () + "" + method. getname () + ""); Class <?> [] Types = method. getparametertypes (); For (class <?> Type: types) {system. Out. Print (type. getname () + "") ;}system. Out. println ();}}}}

Struts

From webwork to version 2.0, It is struts. Now the company's WAP project is in use, and finally let me have a learning opportunity.

The learning is mainly based on the template language.

Basic Flow statement:

<S: If test = "% {false}"> <div> will not be executed </div> </S: If> <s: elseif test = "% {true}"> <div> will be executed </div> </S: elseif> <s: else> <div> will not be executed </div> </S: else>

The character length exceeds the limit. If the number exceeds 28, it is automatically intercepted and displayed .......

 
<P class = "listdescription"> <s: If test = "description. length ()> 28 "> <s: property value =" description. substring (0, 28) + '...... '"/> </S: If> <s: else> <s: property value =" Description "/> </S: else> </P>

How do I transmit PARAMETERS ON THE include page?

<! -- Return entry --> <s: Set Name = "variable" value = "'album '"/> <s: set Name = "variable2" value = "'details'"/> <% @ include file = "public_new/returnbar. JSP "%> <! -- // Return result -->

The introduced page is as follows:

 
<% @ Page Language = "Java" contenttype = "text/html; charset = UTF-8" pageencoding = "UTF-8" %> <! -- Return entry --> <Div class = "returnbar"> <Div class = "gobackbtn" Title = "back to previous page" onclick = "history. go (-1); "> </div> <a href = ". "Title =" back to home "> <Div class =" homebtn "> </div> </a> <s: property value =" # variable "/> <s: property value = "# variable2"/> </div> <! -- // Return result -->

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.