Struts2--初学笔记,都是基础,务必熟记。

本文介绍了Struts2框架中标签使用的三个基本原则,并详细说明了如何在JSP页面中通过Struts2标签获取不同作用域内的对象。包括应用、会话、请求范围的对象及请求参数。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. Tag使用的三个原则:

struts2/struts-2.0.11/docs/docs/tag-syntax.html

Boiled down, the tag attributes are evaluated using three rules.

  1. All String attribute types are parsed for the "%{ ... }" notation.
  2. All non-String attribute types are not parsed, but evaluated directly as an expression
  3. The exception to rule #2 is that if the non-String attribute uses the escape notion "{%{}", the notation is ignored as redundant, and the content evaluated.  

2. JSP里面获取Servlet / JSP Scoped Objects

There are a couple of ways to obtain access to ValueStack from JSPs.

Application Scope Attribute:<s:property value="%{#application.myApplicationAttribute}" />

Session Scope Attribute:<s:property value="%{#session.mySessionAttribute}" />

Request Scope Attribute:<s:property value="%{#request.myRequestAttribute}" />

Request Parameter:<s:property value="%{#parameters.myParameter}" />

Context Scope Parameter:<s:property value="%{#myContextParam}" />

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值