注册功能完成之后,就到了登录功能了。先在主页上添加登录按钮,用来跳转页面到登录界面login.jsp:
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>
<br/>
<form action="getMess.action" method="post">
<input type="submit" value="查询">
</form>
<br/>
<a href="register.action">注册</a>
<a href="login.jsp">登录</a>
</body>
</html>
然后在web文件夹下新建login.jsp,代码如下:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>login</title>
</head>
<body>
<form action="login.action" method="post">
<input type="text" placeholder="username" id="username" name="username"><br>
<input type="password" placeholder="password" id="password" name="password"><br>
<input type="submit" value="登录">
</form>
</body>
</html>
然后在struts.xml中添加login action,代码如下:
<a