在上一篇文章中我们成功实现了通过hibernate向数据库中添加数据的功能,这一篇文章会将这个功能稍微进行一些修改,改成从前台页面输入需要插入数据库中的数据,然后将其添加到数据库中的功能。
首先,将index.jsp进行一些修改,代码如下:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>$Title$</title>
</head>
<body>
<form action="hello.action" method="post">
<input type="text" name="uname" id="uname">
<input type="submit" value="增加">
</form>
</body>
</html>
这里增加了一个需要向action层传递的数据uname,我们在action层对此数据进行接受,并将其向spring层传递:
LoginAction的代码:
package com.kay.s