Flex是以JSTL形式嵌入Jsp的,Jsp檔案裡的頭一句就是
<%@ taglib uri="FlexTagLib" prefix="mm" %>
下面是啟動並執行
原始碼test.jsp
其中對jsp中的輸入輸出字元進行了編碼,我用的是Tomcat5.5,用其他伺服器的話可能會不同!
<%@ taglib uri="FlexTagLib" prefix="mm" %>
<%@ page contentType="text/html; charset=utf-8" %>
<html>
<%
String data = (String)session.getAttribute("data");
String name = new String(request.getParameter("name").getBytes("8859_1"), "utf-8") ;
String email = new String(request.getParameter("email").getBytes("8859_1"), "utf-8") ;
data = data + "<mydata name='"+name+"' email='"+email+"'/>";
//System.out.println(data);
session.setAttribute("data", data);
%>
This is html powered by jsp<br>
<mm:mxml>
<mx:Application width="300" height="200" xmlns:mx="http://www.macromedia.com/2003/mxml">
<mx:Model id="myModel">
<%= session.getAttribute("data") %>
</mx:Model>
<mx:DataGrid width="100%" height="100%" dataProvider="{myModel.mydata}"/>
</mx:Application>
</mm:mxml>
<form action="" method="post">
name: <input name="name"><br>
email: <input name="email"><br>
<input type="submit" value="添加">
</form>
</html>