使用JSP(Eclipse)将数据插入数据库(XAMPP,MySQL)

时间:2017-12-16 03:35:49

标签: java mysql eclipse jsp servlets

所以我试图将JSP表单中的(插入)记录注册到数据库(XAMPP,MySQL)。详情如下:

register.jsp

didSet

RegisterController.java

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>

    <form action = "RegisterController" method = "post">
        <input type = "text" name = "email" placeholder = "Your e-mail"><br><br>
        <input type = "text" name = "firstname" placeholder = "First name"><br><br>
        <input type = "text" name = "lastname" placeholder = "Last name"><br><br>
        <input type = "text" name = "address" placeholder = "Home address"><br><br>
        <input type = "text" name = "phone" placeholder = "Your phone number"><br><br>
        <input type = "password" name = "password"><br><br>
        <input type = "submit" name = "submit" value = "Register">
    </form>

</body>
</html>

因此,当我在localhost上运行并输入详细信息时,它只显示一个空页面,并且该表没有任何更新.Debugging显示没有错误以及运行时。我正在使用Eclipse Luna和Dynamic Module 2.5以及Apache Tomcat 7.0。

1 个答案:

答案 0 :(得分:0)

您必须在项目中添加Mysql jar,并且必须将RegisterController文件映射到Web.xml文件(WebContent\WEB-INF\Web.xml

并检查Register.jsp中“表单操作”的路径,Web.xml中的“url-pattern”两者必须相同。