ognl表达式是什么_ognl表达式#号_ognl表达式

电脑杂谈  发布时间:2017-02-15 20:59:56  来源:网络整理

ognl表达式是什么_ognl表达式#号_ognl表达式

ognl表达式ognl表达式

1.在jsp页面上直接使用struts2的s标签,要求必须经过FileterDispatcher过滤,否则总会报错

org.apache.jasper.JasperException: The Struts dispatcher cannot be found. This is usually caused by using Struts tags without the associated filter. Struts tags are only usable when the request has passed through its servlet filter, which initializes the Struts dispatcher needed for this tag.

解决办法:

<filter>
		<filter-name>struts2</filter-name>
		<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
	</filter>
	<filter-mapping>
		<filter-name>struts2</filter-name>
		<url-pattern>*.action</url-pattern><!--过滤主要操作 -->
	</filter-mapping>
	<filter-mapping>
		<filter-name>struts2</filter-name>
		<url-pattern>*.jsp</url-pattern>
<!--因为若在jsp页面使用struts标签,就必须经过FilterDispacher的过滤,这样配置便可保证所有的jsp都经过FilterDispatcher了,否则要为每一个jsp写配置一个action地址转入-->
	</filter-mapping>

2.在使用struts标签的过程中,会生成一些table,td标签并且标签自动换行,去除的方法如下:

1.在标签中加theme=""

<s:textfield theme="" ></s:textfield>--普通文本框的使用

2.在struts.xml文件中进行配置:

ognl表达式#号_ognl表达式_ognl表达式是什么

<constant value="" />

这便可去除标签并解决自动换行的问题。

3.ognl表达式不能直接访问static方法的问题

今天在页面直接用ognl调用方法:

<s:property value="@com.DateUtil@getTimeArray()"/>来获取时间,但始终进不去方法。

后来把此代码拷到另外一个工程中,就可以正常调用方法了。

查了网上资料,原因如下,有些struts2的配置项里其中有一个名为struts.ognl.allowStaticMethodAccess的配置项默认是false;

解决办法:

ognl表达式是什么_ognl表达式#号_ognl表达式

在struts.properties中配置:

struts.ognl.allowStaticMethodAccess=true

或者

在struts.xml中配置:

<constant name="struts.ognl.allowStaticMethodAccess" value="true" />

可直接调用方法:

eg: <a

href="http://v.t.sina.com.cn/share/share.php?url=http://<s:property value="couponDetailVO.cityGbName"/>.koubei.com/youhuiquan/<s:property value="couponDetailVO.id"/>&title=<s:property value="@java.net.URLEncoder@encode(couponDetailVO.name,'UTF-8')"/>"

target="_blank">分享到新浪微博</a>

问题解决


本文来自电脑杂谈,转载请注明本文网址:
https://www.pc-fly.com/a/jisuanjixue/article-32634-1.html

    相关阅读
      发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

      热点图片
      拼命载入中...