记录一下在登录界面出现的一些小问题
出现问题
本来想在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>
标签即可。
本文作者:又一岁荣枯
本文链接:https://www.cnblogs.com/java-six/p/15641119.html
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。
分类:
Web后端
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步