记录一下在登录界面出现的一些小问题

出现问题

本来想在jsp页面实现登录注册方法,由于登录方法在原来实现过,所以这一次就本着cv工程师的原则直接把他复制了过来,想不到他的参数老是提交不上去,我感到很疑惑,同样没有报错,也没有404。

排查问题

于是我将其与本来的代码进行仔细对比,终于,在jsp中发现了问题。

解决问题

刚开始写jsp页面的时候,我感觉超链接按钮比提交按钮好看的多,于是这一次作死的使用了herf超链接

<div align="center">
    <div>账号:<input type="text" name="account"></div>
    <div>密码:<input type="password" name="password"></div>
    <div>
        <button><a href="login">登录</a></button>
        <button><a href="login/zhuce.jsp">注册</a></button>
    </div>
</div>

由于超链接是无法将<input>中的参数提交上去的,所以Servlet就无法接收到输入的数值,也就无法对数据库进行操作了。

修改后的代码

<form action="login" method="post">
<div align="center">
    <div>账号:<input type="text" name="account"></div>
    <div>密码:<input type="password" name="password"></div>
    <div>
        <input type="submit" value="登录">
        <button><a href="login/zhuce.jsp">注册</a></button>
    </div>
</div>
</form>

在外部加上<form>标签即可。

posted @ 2021-12-04 10:25  又一岁荣枯  阅读(44)  评论(0编辑  收藏  举报