JavaWeb标准标签

目录

使用web.xml设置网页首选项

双击web.xml

标准标签

包含:把别的页面的属性包含到该界面

 传参:与上面一起连用

转发

相当于实例化

setproperty:给userBean属性设置

getproperty:拿userBean属性的值

login.jsp 界面

 index.jsp


使用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>

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值