setcontenttype.jsp

来自「JSP课件以及一个网上书店系统程序,带数据库」· JSP 代码 · 共 50 行

JSP
50
字号
<%@ page contentType="text/html;charset=GB2312" language="java" %>
<html>
	<head>
		<title>response对象的setContentType方法</title>
	</head>
	<body>
		<table width="80%" border="0" align="center" cellpadding="0" cellspacing="1" ID="Table1">
			<tr bgcolor="#E6E6E6">
				<th width="364" height="27">
					图书名称</th>
				<th width="150">
					出版社</th>
				<th width="140">
					定价</th>
			</tr>
			<tr align="center" height="25">
				<td width="364" height="18">ASP.NET网络编程</td>
				<td>清华大学出版社</td>
				<td>¥128元</td>
			</tr>
			<tr align="center" height="25">
				<td width="364" height="18">Java现代软件开发技术</td>
				<td>清华大学出版社</td>
				<td>¥128元</td>
			</tr>
			<tr align="center" height="25">
				<td width="364" height="18">C++基础教程</td>
				<td>清华大学出版社</td>
				<td>¥128元</td>
			</tr>
		</table>
		<h3>最近浏览过的图书</h3>
		<form action="setContentType.jsp" method="get" name="form1" id="form1">
			<p><strong> 【选项】将文档保存为以下哪个格式? </strong>
				<br>
				<input name="t" type="radio" value="text/html" checked ID="Radio1"> 文本文件 <input name="t" type="radio" value="application/x-msexcel" ID="Radio2">
				Office Excel文件 <input name="t" type="radio" value="application/msword" ID="Radio3">
				Office Word文件
				<br>
				<br>
				<input type="submit" name="Submit" value="保存" ID="Submit1">
			</p>
		</form>
		<%
		String doctype=request.getParameter("t");
		response.setContentType(doctype);
		%>
	</body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?