BASIC认证html通过办法

本文展示了一个使用Java和HTML编写的简单登录页面示例。该示例包括了基本的用户名和密码输入框,并通过POST方式向指定地址提交数据。此外还使用了jQuery来增强页面的交互体验。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
<title>Insert title here</title>
</head>
<body onload="login()"><!--
     <iframe width="100%" height="500px" scrolling="auto" src="testServlet.do"></iframe>
     
 -->
 <form id="f1" action="http://127.0.0.1:8081/test/userAction!sysLogin.action" method="post" onsubmit="login()">
    <fieldset>
    <legend>Login</legend>
    <label for="username">username:</label>
    <input type="text" id="username" name="username" value="111">

    <label for="password">password:</label>
    <input type="password" id="password" name="password"  value="111">

    <input type="submit" value="subject">
    </fieldset>
</form>
</body>
<script>

function login() {
    var username = document.getElementByIdx_x("username").value;
    var password = document.getElementByIdx_x("password").value;
    xhr = new XMLHttpRequest();
    xhr.open("POST", "http://127.0.0.1:8081/test/userAction!sysLogin.action", false, username, password);
    xhr.send(null);
    return xhr.status == 200;
}
$(function(){
$("#f1").submit();
});
</script>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值