1. Create the package name first:
2. Creating entity Classes
Refer to the two-dimensional table, consider each field name, type
Create a class in the entity package with the following code:
Public class House { private String ID; Private String name; Private String address; Public String getId () { return ID; } ... .. // other
3. Establishing the Business Logic interface (Houseservice) and implementation (Houseserviceimpl)
Manager Write Interface: Public InterfaceHouseservice { PublicListgetallhouses ();} Brother Write implementation class: @Override PublicListgetallhouses () {List<House> houselist =NewArraylist(); //1 Bald-headed home forest, number 188th.//2 Bear Big House forest tree hole Phase 3 floorHouse H1 =NewHouse (); House H2=NewHouse (); H1.setid ("1"); H1.setname ("Great place to be."); H1.setaddress ("Forest No. 188th"); H2.setid ("2"); H2.setname ("The home of the Bear"); H2.setaddress ("3/F, forest Tree cave Phase One"); Houselist.add (H1); Houselist.add (H2); returnhouselist; }
4. Create a (Servlet) controller, call the service Fetch DataSet list "Send the results to the JSP and jump to the past"
Create a new servlet:houseaction_showallhoses in the action package
4. Create a show.jsp to get the list from the Request object
Core code: Request.getattribute ("Houselist_label");
The rest of the code in the reference war package is the same as the previous example.
Servlet accesses JavaBean and passes results to JSP