一個簡單的JSP頁面

來源:互聯網
上載者:User
<%--     Document   : a    Created on : 2008-6-16, 11:59:30    Author     : 王界涵--%><%@ page contentType="text/html" pageEncoding="UTF-8"%><!--使用哪些包--><%@ page import="java.util.List"%><%@ page import="cma.model.cf.Cfdictarea"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><!--後台綁定的JAVABEAN--><jsp:useBean   id="testJspBean" scope="page" class="cma.cf.testJspVBean"/><html>    <head>        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">                    <title>JSP Page</title>         <link type="text/css" rel="stylesheet" href="../../css/StyleSheet.css" />    </head>    <body>        <form id = "from1" name = "from1" method="post">            <table border="1">                    <tr>                        <td> <select name="">                                <!--當所有option都有selected時,不可用selected="",否則失效-->                                <option value = "1">1</option>                                <option selected="selected" value ="2">2</option>                                <option value ="3" >3</option>                                <option value ="4" >4</option>                        </select></td>                        <td>                            <select name = "select1">                                <!--<option selected>==所有地區==</option>-->                                <%            List list = testJspBean.getBatchidgroups();//擷取地區列表            for (int i = 0; i < list.size(); i++) {                Cfdictarea cf = new Cfdictarea();                cf = (Cfdictarea) list.get(i);//將LIST的每項對象化                                 %>                                 <!--綁定下拉選並用SELECTED屬性判斷哪個被選中-->                                <option value="<%=cf.getAreacode()%>"  <%=cf.getAreacode().toString().equals("ATJ") ? "selected" : ""%>><%=cf.getAreaname()%></option>                                 <%}%>                             </select>                        </td>                    </tr>                    <tr>                        <td>                            <%            //測試文字框綁定            String k = "ATJ";                            %>                            <input type="text"  value="<%=k.equals("ATJ") ? "selected" : ""%>"/>                        </td>                        <td> </td>                    </tr>            </table>            <!--綁定地區列表-->            <table border="1">                <thead>                    <tr>                        <th>地區代碼</th>                        <th>地區名稱</th>                    </tr>                </thead>                <tbody>                        <%            List viewList = testJspBean.getBatchidgroups();            for (int i = 0; i < viewList.size(); i++) {                Cfdictarea cfa = new Cfdictarea();                cfa = (Cfdictarea) viewList.get(i);                                 %>                    <tr>                        <td><%=cfa.getAreacode()%></td>                        <td><%=cfa.getAreaname()%></td>                    </tr>                    <%}%>                </tbody>            </table>        </form>    </body></html>
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.