<%-- COPYRIGHT (C) 2014-2015 BY MULDINI. ALL RIGHTS RESERVED. --%> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <% request.setCharacterEncoding("UTF-8"); %> <%-- 从当前page中取id为singer的对象,该对象类型为com.muldini.myface.common.Singer --%> <%-- 若无则新建1个Singer类型对象,该对象id为“singer”,并将其存入page。默认scope就是page--%> <jsp:useBean id="singer" class="com.muldini.myface.common.Singer" scope="page" /> <%--把客户端request中的name和rank参数值分别赋给id为singer的对象的name和rank属性 --%> <jsp:setProperty name="singer" property="name" param="name"/> <jsp:setProperty name="singer" property="rank" param="rank"/> <%--TOSHOW1<jsp:setProperty name="singer" property="*"/> --%> <%--TOSHOW2<% String player = "Inzaghi"; %> <jsp:setProperty name="singer" property="name" value="<%=player %>"/>--%> <%--TOSHOW3<jsp:setProperty name="singer" property="name" value="Pippo"/>--%> <!DOCTYPE html> <html> <head> <link rel="stylesheet" type="text/css" href="css/myface.css"> <title>I am a player</title> <script type="text/javascript"> function validate() { if (myform.name.value == null) { alert("请您输入巨星名"); return false; } if (myform.rank.value == 0) { alert("请您选择巨星排名"); return false; } return true; } </script> </head> <body> <div> <div id="left"> <img id="singer-img" src="image/iamasinger.png"> </div> <div id="right"> <%--取得id为singer的对象的name和rank属性值 --%> 球星: <jsp:getProperty name="singer" property="name" /><br> 排名: <jsp:getProperty name="singer" property="rank" /><br><br><br> <form name="myform" method="post" action="iamasinger.jsp" onsubmit="return validate()"> Enter a 球星 name: <input type="text" name="name" size="25"><br><br> Choose a Player 排名: <select name="rank"> <option value="0">请选择</option> <option value="1">第1名</option> <option value="2">第2名</option> <option value="3">第3名</option> <option value="4">第4名</option> <option value="5">第5名</option> <option value="6">第6名</option> <option value="7">第7名</option> </select> <input type="submit" value="Submit"> </form> </div> </div> </body> </html>
echo_kinchao