struts2标签之url标签

 
下面是struts2标签的常用的用法
<s:url value="/images/copyright.jpg" />
<s:url action="list" namespace="/qxgl" />
一定要注意:url中includeParams的属性的默认值是get,如果没有在struts.xml指定新的值,那么使用url标签引用的所有的静态文件都会带上通过get方法传递的参数值。
另外: includeParams的属性值还有none、all
all,是把get和post中的参数加入到 url参数中 ;
none是不把参数加入到url中;

例如:你在detail.jsp中写入

<link href="<s:url value="/css/styleqxgl.css"/>" rel="stylesheet"
    type="text/css">

在浏览器中输入http://localhost/detail.jsp?id=5

<link href="/web应用名称/css/styleqxgl.css?id=5" rel="stylesheet"
    type="text/css">
这样浏览器就又下载了一次styleqxgl.css,如果你的系统放在公网上,那么带宽的费用是很贵的,使用浏览器的缓存,可以有效的利用带宽,节约成本。

解决这个问题的办法有两个,一个是<s:url value="/css/styleqxgl.css"  includeParams="none"/>

另外一个就是在struts.xml中配置,参考下文:

Setting a default value for includeParams

The property struts.url.includeParams can be used to set the default value of the includeParams attribute.

Setting the default value of includeParams
<struts>
...
<constant name="struts.url.includeParams" value="none" />
...
</struts>

See Constant Configuration for further information.

Parameters

Name
Required
Default
Evaluated
Type
Description
actionfalse
falseStringThe action to generate the URL for, if not using value
anchorfalse
falseStringThe anchor for this URL
encodefalsetruefalseBooleanWhether to encode parameters
escapeAmpfalsetruefalseBooleanSpecifies whether to escape ampersand (&) to (&amp or not
forceAddSchemeHostAndPortfalsefalsefalseBooleanSpecifies whether to force the addition of scheme, host and port or not
idfalse
falseStringDeprecated. Use 'var' instead
includeContextfalsetruefalseBooleanWhether actual context should be included in URL
includeParamsfalsegetfalseStringThe includeParams attribute may have the value 'none', 'get' or 'all'
methodfalse
falseStringThe method of action to use
namespacefalse
falseStringThe namespace to use
portletModefalse
falseStringThe resulting portlet mode
portletUrlTypefalse
falseStringSpecifies if this should be a portlet render or action URL. Default is "render". To create an action URL, use "action".
schemefalse
falseStringSet scheme attribute
valuefalse
falseStringThe target value to use, if not using action
varfalse
falseStringName used to reference the value pushed into the Value Stack
windowStatefalse
falseStringThe resulting portlet window state
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值