目录
使用web.xml设置网页首选项
新建项目,按next,勾选Generate web.xml deployment descripor
双击web.xml
把 <welcome-file>自己的网页</welcome-file>
设置好后每次运行该项目就会跳到该界面
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
id="WebApp_ID" version="4.0">
<display-name>web07</display-name>
<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>
</web-app>
标准标签
<jsp:include page="网页" >包含:把别的页面的属性包含到该界面
<jsp:param value="1" name="type"/>传参:与上面一起连用
<jsp:forward page="页面">转发
<jsp:useBean>相当于实例化
setproperty:给userBean属性设置
getproperty:拿userBean属性的值
login.jsp 界面
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<jsp:include page="index.jsp">
<jsp:param value="1" name="type"/>
</jsp:include>
<jsp:include page="index.jsp">
<jsp:param value="2" name="type"/>
</jsp:include>
<jsp:include page="index.jsp">
<jsp:param value="3" name="type"/>
</jsp:include>
<%--<jsp:forward page="index.jsp"></jsp:forward>
--%>
</head>
<body>
<form action="dologin.jsp">
<input type="text" name="id"><br>
<input type="text" name="username"><br>
<input type="password" name="password"><br>
<button>提交</button>
</form>
</body>
</html>
index.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style type="text/css">
.h1{
border:10px solid red;
height:100px;
}
</style>
</head>
<body>
<%
String type=request.getParameter("type");
String data="";
if("1".equals(type)){
data="热门商品";
}
if("2".equals(type)){
data="热销商品";
}
if("3".equals(type)){
data="特价商品";
}
%>
<h1 class="h1"><%=data %></h1>
</body>
</html>