Struts2 - Stack Context
<%@ page contentType="text/html; charset=UTF-8" language="java" errorPage="" %> <%@ taglib prefix="s" uri="/struts-tags"%> <!DOCTYPE html> <html> <head> <title>WELCOME</title> </head> <body> Value Stack:<br> ユーザ名:<s:property value="username"/><br> パスワード:<s:property value="password"/><br> Stack Context<br> ユーザ名(リクエストパラメータ):<s:property value="#request.username"/><br> パスワード(リクエストパラメータ)<s:property value="#request.password"/><br> <!-- debugタグを使い --> <s:debug /> </body> </html>
※要約
- Struts2はOGNL(Object Graph Navigation Language)を使いデータアクセスする
- Stack Context内にデータを保存し、#オブジェクト名でアクセスする
- Value StackはStack Contextのルートオブジェクトであり、#を使わずにアクセスできる。
- ActionインスタンスはValue Stack内に保存される。
- parameters, request, session, application, attrなど命名オブジェクトが存在する
※static access
<constant name="struts.ognl.allowStaticMethodAccess" value="true" />