注册功能完成之后,就到了登录功能了。先在主页上添加登录按钮,用来跳转页面到登录界面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

这篇博客详细介绍了如何在IntelliJ IDEA中搭建一个网站的登录功能。从在index.jsp添加登录按钮,到创建login.jsp、配置struts.xml,再到编写action层的LoginAction类、实现业务逻辑,以及处理登录成功的loginSuccess.jsp页面,逐步展示了整个流程。
最低0.47元/天 解锁文章
3946

被折叠的 条评论
为什么被折叠?



