2012-05-14 13 views
0

我有以下的JSP腳本小程序:JSP小腳本在Struts 2個的標籤

<input type="text" name="user.emailAddress" 
    value="<%=UserServiceFactory.getUserService().getCurrentUser().getEmail()%>" 
    readonly="readonly"/> 

如何將其轉換爲Struts 2的標籤

<s:textfield /> 

避免小腳本。

+0

你爲什麼要scriptlet而當S2提供了一個更清潔的方式來做到這一點,併爲每個標籤XSD它將無法使用小腳本。 –

+0

我不想要scriptlet,我想要的是使用訪問GAE中的用戶服務的textfield標籤。 –

+0

您可以要求OGNL爲您完成這項工作.OGNL有權從JSP中調用方法。 –

回答

1

打開此頁面時,如果使用的是準備方法。在該方法中設置此電子郵件地址。

user.setEmailAddress(UserServiceFactory.getUserService().getCurrentUser().getEmail()) 

你的HTML將

<s:textfield name="user.emailAddress" readonly="true" />