Javaweb Learn 007-4 pages, 5 SQL statements (add, view, modify, delete) 2016-12-2

Source: Internet
Author: User

Need to review the Knowledge: Association query

=================================================================================
class module
Student Module
Course Modules
Hobby Module
User Information Module

The first thing a project has to do is write Tbuser, which corresponds to login.


Each module has a list page, add operation, view operation, modify operation, delete operation

DAO level is the level of database connection, it needs to write 6 Java method;
The biz level is the business logic judgment, which only needs to return the DAO result to the biz;
Web-level is the writing of each servlet;

For each module, the first is entity--and DAO--and Biz-->jsp and servlet authoring

===================================================

① for loop for each list page, configure Taglib with URI property and prefix property
②<c:foreach> must write 2 attributes
①items: Key key from the servlet must be written with an El expression for example: ${glist}
②var: Every time a loop is entered into the object
for (Grade g:list) {
Sysout (G.getgradeid ())
Sysout (G.getgradename ())
}

-------------------------------------------------------------------------------------
Request.setattribute (' Rows ', rows) What's the use of this key?


Note: When you do non-null validation, the JavaScript statement is written in the child element of the head

--------------------------------------------------------------------------------------------
1.
Why view the page int stuid = Request.getparemeter
SELECT * FROM student where Stuid = 1
Because the view needs to be checked by the parameter ID, the page is passed to the servlet an ID value,
What about modifying the page?
Update student Set stuname = ' Where stuid= '
So modify the page not only need the ID value, also need to pass to a name value, to hide the primary key

But what's the use of hiding the primary key?

2.
<a href= "Dodetailstudent.action?stuid=${student.stuid}" > View </a>
<a href= "Toupdatestudent.action?stuid=${student.stuid}" > Modify </a>
<a href= "Dodeletestudent.action?stuid=${student.stuid}"
onclick= "return confirm (' Confirm Delete message? '); ' > Delete </a>


---======================
3.
Students have to have classes in their tables.
Indicate which class the student is in, related query

Is-a is inherited
Has-a is a package

The writing of the Vo class:
is to query the students, to display the corresponding class name, that is, the associated query

4 pages, 5 SQL statements, 6 Java methods

Grade module (one side) Student Module (multi-party)
A class can have multiple students, which is the relationship established in the relational model diagram

Should be one of the primary keys of a party acting as a foreign key to many Parties
For example: Query student must be able to see grade information,
But query grade don't have to see student information
------------------------------------------------------------------------------------------
In this case, the student module is the code of the many side of the writing and grade module is one of the party code writing
Difference:
Need to query to show the operation of the class: Queryall-detail.
Only the code for these two operations needs to be changed.

Public list<studentvo> queryallstudent ();
Public Studentvo detailstudent (int id);

is to replace the place where it was supposed to be student Studentvo
------------------------------------------------------------------------------------
But here's the problem:
Previously learned Database association, that is, the relationship model diagram drawing time, remember is not very clear.

How do I implement the grade and student associations?
Is it just when you're building a student table that you can write more than one column of grade's primary key?

Javaweb Learn 007-4 pages, 5 SQL statements (add, view, modify, delete) 2016-12-2

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.