基於flex4技術從零開發flex部落格系統:8 using jsp and jstl

來源:互聯網
上載者:User

一,using jsp

App Engine java提供對JSP,JSTL的幾乎完全支援。本課主要介紹如何在GAE for java中使用jsp及jstl。

開啟eclipse菜單->Preferences->Java->Installed JREs,添加jdk安裝目錄,並設為預設。預設eclipse僅指向了jre目錄。

開啟gapp_flexblog項目,在war目錄下添加jsp檔案greeting_via_jsp.jsp,如下:

<%@page contentType="text/html;charset=UTF-8" language="java" %>
<%@page import="sban.flexblog.HelloWorldUsingJPA"%>
<%@page import="sban.flexblog.GreetingEntity"%>
<%@page import="java.util.List"%>
<html>
<body>

<%
if (null != request.getParameter("message"))
{
        String action = request.getParameter("message");
        response.getWriter().write(action + "<br />");
}
%>

<form action="/gapp_flexblog/hello" method="post">
    user:<input name="username" value="sban" maxlength="50" ></input><br />
    greeting content:<input value="greeting content1" name="greetingContent" maxlength="250" ></input><br />
    <input type="hidden" name="action" value="new" />
    <input type="submit" value="Post Greeting" />
</form>

<div>
<form action="/gapp_flexblog/hello" method="post">
        <input type="submit" value="Delete All Greetings" />
        <input type="hidden" name="action" value="delall" />
</form>
</div>

<div>
        <h3>Greetings list:</h3>
        <ul style="list-style: decimal;">
        <%
        HelloWorldUsingJPA operator = new HelloWorldUsingJPA();
        List<GreetingEntity> greetings = operator.getAllGreetings();

        if (greetings.size() > 0)
        {
                for(GreetingEntity greeting : greetings)
                {
                        %>
                        <li>
                                id:<%= greeting.getId() %>
                                user:<%= greeting.getUser() %>
                                greetingContent:<%= greeting.getGreetingContent() %>
                                date: <%=greeting.getDate().toString() %>
                        </li>
                        <%
                }
        }else{
                %>
                <li>Empty!</li>
                <%
        }
        %>
        </ul>
</div>
  </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.