jsp - javaweb about MVC framework
PHP中文网
PHP中文网 2017-05-16 17:06:11
0
2
719

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.

  1. Do we need to write database connection code in servlet? If written in DAO, how to connect?
  2. How to transfer data between DAO servlet JavaBeans? Now we only know that DAO and JavaBean are passed through DAO and VO.

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.

PHP中文网
PHP中文网

认证0级讲师

reply all(2)
仅有的幸福

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!

我想大声告诉你

How to obtain the information submitted by the form for processing.

The page assumptions are as follows:

<form action="/SignUpServlet" method="post">
    <input type="text" name="username">
</from>

In SignUpServlet.javadoPost(同form中的method对应)中,通过request.getParameter("username") you can get the username (in string form) entered on the front-end page

Do I need to write database connection code in servlet? If written in DAO, how to connect?

DAO定义及实现相应方法(通过连接数据库),servletCall the interface directly

How to transfer data between DAO servlet JavaBean?

servlet中调用DAO,JavaBeanDAOservlet will appear.

It’s hard to say this. You can leave it to my email and I will send you examples.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template