<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>后台管理系统</title>
<link href="/ehouse/css/admin/login.css" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="login">
<h1>盛世翌豪后台管理系统</h1>
<p>
<input type="text" id="name" value="admin"
placeholder="用户名">
</p>
<p>
<input type="password" id="password" value=""
placeholder="密码">
</p>
<p class="submit">
<input type="submit" id="commit" value="登陆">
</p>
</div>
</div>
</body>
</html>
<script type="text/javascript" src="/ehouse/js/jquery-3.2.1.min.js"></script>
<script type="text/javascript">
$("#commit").click(function(){
var name =$("#name").val();
var password = $("#password").val();
if(name =='admin'&&password =='ehouse'){
location.href="<%=basePath%>admin/login.html";
}else{
alert("用户名或密码不正确");
}
});
</script>
你可能用了某些代理。
用相对路径替换绝对路径便可,像这样
顺便提醒一下,把用户名和密码写在 javascript 里是很不妥当的,任何人都有可能看到它们