In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article is about how to use JSP and JDBC. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
1.
Equivalent to
2 、
Anni.ContactDao is a bean that encapsulates database operations.
Equivalent to
In the above code, just to create an instance of an object, why not use new? it's much less code than this, and it's easier to understand. Why do we insist on using jsp:useBean?
Notice the scope= "application" in the tag. Application is one of the four scopes we have introduced.
We first get the object corresponding to contactDao from application, and then determine whether the result is null. If it means that this variable has not been initialized for null, we need to use new to create an object instance and put it into application. * * what we get is this contactDao instance.
3. Create.jsp contains information about form submission
Save.jsp form submission information processing
Contact is the get,set method with the corresponding attribute in the corresponding entity bean name
Equivalent to
First take the contactDao from the application, and then create a contact. No scope was specified when the contact was created. By default, this local variable is only created using new, which does not affect any scope. Jsp:setProperty is something new, and its purpose is to set data for a javabean. We have previously created a contact instance using jsp:useBean, and now we set the data for this instance through name= "contact". Property can specify a property, such as property= "username", or use an asterisk (*) to batch set all the properties that can be found. This jsp action is actually equivalent to the following code.
Contact.setUsername (request.getParameter ("username")); contact.setSex (request.getParameter ("sex")); contact.setEmail (request.getParameter ("email")); contact.setQq (request.getParameter ("qq")); contact.setDescn (request.getParameter ("descn")); contactDao.save (contact); response.sendRedirect ("list.jsp"); Thank you for reading! This is the end of the article on "how to use JSP and JDBC". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.