First, sql database operations:
1, when three-table query, the final condition due to the current field must determine which table belongs to, it is necessary to specify which table to be judged in the fields as:
And then followed by the time limit, it is necessary to pay attention to add, to avoid the system can not identify the specific parameters:
// Search through the employee information table according to the conditions public List <the Message> getMessageByCondition (for condition Condition for condition Condition, int index, the currentCount Integer) throws SQLException { QueryRunner QR = new new QueryRunner (MyDBUtils.getDataSource ()); String SQL = "SELECT * from Person person.ppid = position.ppid the ON position the Join the JOIN Department person.pdid = department.pdid the ON = WHERE. 1. 1 " ; // needs to be set in the result in (due to the length of the array can not be changed) to the DISTINCT weight ArrayList <Object> arr = new new the ArrayList <Object> (); // TRIM () is to remove both spaces IF (condition.getPpid () =! null && condition.getPpid() != "") { // sql += " and pposition like ?"; && condition.getPteam() != "" // arr.add("%" + condition.getPposition() + "%"); sql += " and person.Ppid=?"; arr.add(condition.getPpid()); } if (condition.getPdid() != null && condition.getPdid() != "") { sql += " and person.Pdid=?"; arr.add(condition.getPdid()); } if (condition.getPteam() != null && condition.getPteam() != "") { sql += " and pteam=?"; arr.add(condition.getPteam()); } sql += " limit ?,?"; arr.add(index); arr.add(currentCount); List<Message> list = qr.query(sql, new BeanListHandler<Message>(Message.class), arr.toArray()); return list; }
2, when the five-table query query directly on the line:
String sql = "SELECT * FROM information JOIN person ON person.pname=information.pname JOIN human ON human.username = information.username JOIN `position` ON person.ppid=position.ppid JOIN department ON person.pdid=department.pdid ";
3, the Table 1 query out of the results according to the conditions placed on the table 2 in a field:
String sql = "INSERT INTO `human` (username) SELECT(SELECT `username` FROM information WHERE istate ='通过')";
4, delete the data in Table 2 according to the check out the result in Table 1:
String sql = "delete from information where pname =(select pname from person where pid=?)";
Two, JavaBean class:
Because reducing redundant data, some of the data table will need to be re-sub-table queries, so if they wish to see all the information, then, the need for multi-table - to build a number of data classes:
1, the form of inheritance can be used: - access to all subclasses such data and its parent class;
Package Penalty for Domain; // all personal information - to inherit login page public class PersonalMessage the extends Information { Private String pwd; Private Integer pid; Private String pposition; Private String pDepartment; Private Integer pteam; Private Integer ppid; Private Integer PDID; public String getPwd () { return pwd; } public void setpwd (String pwd) { the this .pwd = pwd; } public Integer getPid() { return pid; } public void setPid(Integer pid) { this.pid = pid; } public String getPposition() { return pposition; } public void setPposition(String pposition) { this.pposition = pposition; } public String getPdepartment() { return pdepartment; } public void setPdepartment(String pdepartment) { this.pdepartment = pdepartment; } public Integer getPteam() { return pteam; } public void setPteam(Integer pteam) { this.pteam = pteam; } public Integer getPpid() { return ppid; } public void setPpid(Integer ppid) { this.ppid = ppid; } public Integer getPdid() { return pdid; } public void setPdid(Integer pdid) { this.pdid = pdid; } @Override public String toString() { return "PersonalMessage [pwd=" + pwd + ", pid=" + pid + ", pposition=" + pposition + ", pdepartment=" + pdepartment + ", pteam=" + pteam + ", ppid=" + ppid + ", pdid=" + pdid + "]"; } }
2, you can actually build a category, what data need to call time, which is the data:
//请假类 public class Leave implements Serializable { private Integer lid; private Integer pid; private String pname; private Double lday; private String dateStart; private String dateWork; private String lreason; private String leaveType; private String lstate1; private String lstate2; // 额外的属性---连表查询用 private Integer pdid; private Integer pteam; private Integer ppid; private String pdepartment; private String pposition; public Integer getLid() { return lid; } public void setLid(Integer lid) { this.lid = lid;
3, the above code
implements Serializable
It is to achieve serialization, no serious problem.
Third, other small details:
1. Review:
Click the Edit button in the query jsp a row (with the Bank of ID) -> query Bank Servlet all the data according to the Bank of ID -> forwards the request to enter the modification jsp page (you can set certain information can not be changed: disabled = "true") ---> modify Servlet ---> redirection query all information Servlet ---> query total jsp page
2, form a form action is an address which points to the submit button submitted;
3, when the page click on the desired effect does not appear, first check the address click on the event, and then to see whether the Servlet XML in existence;
If there is no data to see if the data has to take, whether to save the data to a domain, JSP page key is correct;
<View the data, in the direct java System.out.println (data), $ directly in jsp {data}>
Fourth, the use layui:
1, when it forms when:
You need to be rendered:
layui.use('form', function () {
var form = layui.form;
form.render();
});
2, the popup :( need to use your js?)
/ * Use the popup * /
layui.use ( 'Layer', function () {
var = layui.layer Layer;
});
// first: active loading jquery module (introduced with their conflict leads to the disappearance of the popup after the contents of the page still exists)
layui.use ([ 'jQuery', 'Layer'], function () {
var = $ // $ layui focus at.
, Layer = layui.layer;
// just behind you usually use jQuery as
/ * set click on the pop-up box * / appears
/ * $ ( "# btn") the click (function () {.
layer.open ({
title: "tips",
of the type: 1,
closeBtn: false,
shadeClose : to true,
Content: $ ( "# info"),
the Cancel: function () {// close the callback function buttons
location.reload ();// refresh the page (to prevent pop-up content is displayed within the page again) when closedfunction () {// Close button callback function
}
});
}) */
3, the use of switching iframe: SRC address when you click on Add;
<!-- 引入iframe --> <iframe class="personList" style="width: 100%; height: 100%; margin-top:0" frameborder="0" src=""></iframe> /* 点击员工信息表按钮 */ $(".personalMessagebtn").on( "click", function() { $(".personList").attr("src", "${pageContext.request.contextPath}/PersonalMessageServlet"); $(".layui-body").css("background", "none"); }); $ (. "ConditionPersonbtn"). ON ( "the Click", function () { / * Click the button staff job information table * / $ ( "layui-body.") CSS ( "background", "none").; $(".personList").attr("src", "${pageContext.request.contextPath}/ConditionPersonServlet", "display", "block") });
4. Other See: https: //www.cnblogs.com/30go/p/11088549.html (invasion deleted)