STS中重定向跳转无效问题

今天接触了request.getParameter,当堂练习是简单的两个网页,一个表单登录界面,一个登录成功界面,一个Servlet界面,运行后可以进入登录界面,可是就是不能登录跳转,由于不认真,四五个小时才发现哪里的问题。

 response.setContentType("text/html;charset=UTF-8");
        String username=request.getParameter("username");
        String password=request.getParameter("password");
    
        
        if("a".equals(username)&&("111").equals(password)){
            response.sendRedirect("/request/1.html");
        }else{
            response.sendRedirect("/request/2.html");
        }

这一段正确

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="/request/jh" method="POST">
用户名:<input type="text" name="username"><br/>
密码:<input type="password" name="password"><br/>
<input type="submit" name="submit" value="提交">
<input type="reset" name="reset" value="重置">
</form>
</body>
</html>

出问题的是这里,本来没有红色区域,被自己蠢到了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值