Javaweb课后习题——设计表单,制作读者选购图书的界面,当读者选中一本图书后,单击“确定”按钮,永“jsp:forward page=”语句将页面跳转到介绍该图书信息页面。

 1 //Type_book.jsp
 2 
 3 <%@page contentType="text/html" pageEncoding="UTF-8" %>
 4 
 5 <html>
 6 <head><title>图书选购界面</title></head>
 7 <body>
 8 <form name="form1"method="post"action="book_show.jsp">
 9 <table bgcolor="#F0FFF0"border="1">
10 <tr bgcolor="#E0FFFF"><td><font color="blue"face="楷体">《Java Web应用开发技术与案例教程》</font></td>
11 <td><font color="blue"face="楷体">《软件工程》</font></td>
12 </tr>
13 <tr bgcolor="#E0FFFF"><td><input type="radio"name="book"value="web"></td>
14 <td><input type="radio"name="book"value="signal"></td>
15 </tr>
16 <tr bgcolor="#E0FFFF"><td colspan="2">
17 <input type="submit"value="提交"></td>
18 </tr>
19 </table>
20 </form>
21 </body>
22 </html>

 

 

 1 //get_book.jsp
 2 
 3 <%@page contentType="text/html" pageEncoding="UTF-8" %>
 4 <%
 5 request.setCharacterEncoding("UTF-8"); %>
 6 <html>
 7 <head><title>get the book</title></head>
 8 <body>
 9 <%
10 String getsel;
11 getsel=request.getParameter("book"); 
12 if(getsel.equals("web"))
13 {%>
14 <jsp:forward page="bookinfo.jsp">
15 <jsp:param name="bookname" value="《Java Web应用开发技术与案例》"/>
16 <jsp:param name="auther" value="张继军、董卫"/>
17 </jsp:forward>
18 <%}else if(getsel.equals("signal")) {%>
19 <jsp:forward page="bookinfo.jsp">
20 <jsp:param name="bookname" value="软件工程"/>
21 <jsp:param name="auther" value="张海藩、牟永敏"/>
22 </jsp:forward>
23 <%}%> 
24 </body>
25 </html>

 

 

 1 //show_book.jsp
 2 
 3 <%@page contentType="text/html" pageEncoding="UTF-8" %>
 4 <%
 5 request.setCharacterEncoding("UTF-8"); %>
 6 <html>
 7 <head><title>图书介绍</title></head>
 8 <body>
 9 <font color="blue"face="楷体">你选择了:
10 <%=request.getParameter("bookname") %></font>    
11 <br/>
12 <font color="blue"face="楷体">该图书的作者:<%=request.getParameter("auther") %></font>
13 </body>
14 </html>

 

 

posted on 2017-10-20 23:24  小星_log  阅读(2181)  评论(1编辑  收藏  举报