For example, on a user registration page, how to obtain the information submitted by the form for processing.
After doGet and doPost are obtained, how to connect to the database to query whether the username (unique) is registered.
There are a lot of questions, and it would be nice to have a simple example to illustrate. Newbie, I haven’t learned the SSH (spring+struts+hibernate) framework yet.
I remember struggling with these problems for the first time like you. In fact, I just started writing these codes. The first thing to know is what you want to do. For example, if you are learning servlet now, it is about how to interact with the browser, accept data, return data, and jump to the page. Wait, for example, if you want to operate the database, the most basic and important thing here is JDBC. You can try to find some relevant information. Generally, there are some simple encapsulated Utils that can help you better understand and quickly operate the database. As for where to write the code, actually You will slowly understand the concept of layering and learn slowly. Don’t rush to learn the framework first!
The page assumptions are as follows:
In
SignUpServlet.java
的doPost
(同form
中的method
对应)中,通过request.getParameter("username")
you can get the username (in string form) entered on the front-end pageDAO
定义及实现相应方法(通过连接数据库),servlet
Call the interface directlyservlet
中调用DAO
,JavaBean
在DAO
和servlet
will appear.It’s hard to say this. You can leave it to my email and I will send you examples.