Am passing some parameters through in Struts2, and am getting below error when there is a HTML special Character in parameter value how can i over come this...?
A herf tage used:
<a href="ManufacturerProducts.action?manufId=<s:property value="manufId"/>&mName=<s:property value="manufName"/>"><img src="<s:property value="manufLogo"/>" alt="<s:property value="manufName"/>" 开发者_StackOverflow中文版/></a>
Error:
12:21:46,034 WARN [OgnlValueStack] Error setting expression ' A Manufacturing Co' with value '[Ljava.lang.String;@4acc69'
ognl.ExpressionSyntaxException: Malformed OGNL expression: A Manufacturing Co [ognl.ParseException: Encountered " <IDENT> "Manufacturing "" at line 1, column 4.
Was expecting one of:
<EOF>
"," ...
"=" ...
"?" ...
"||" ...
"or" ...
"&&" ...
"and" ...
"|" ...
"bor" ...
"^" ...
"xor" ...
"&" ...
"band" ...
"==" ...
"eq" ...
"!=" ...
"neq" ...
"<" ...
"lt" ...
">" ...
"gt" ...
"<=" ...
"lte" ...
">=" ...
"gte" ...
"in" ...
"not" ...
"<<" ...
"shl" ...
">>" ...
"shr" ...
">>>" ...
"ushr" ...
"+" ...
"-" ...
"*" ...
"/" ...
"%" ...
"instanceof" ...
"." ...
"(" ...
"[" ...
<DYNAMIC_SUBSCRIPT> ...
"(" ...
]
at ognl.Ognl.parseExpression(Ognl.java:112)
at com.opensymphony.xwork2.ognl.OgnlUtil.compile(OgnlUtil.java:225)
at com.opensymphony.xwork2.ognl.OgnlUtil.setValue(OgnlUtil.java:209)
at com.opensymphony.xwork2.ognl.OgnlValueStack.trySetValue(OgnlValueStack.java:173)
at com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:160)
at com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:151)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.setParameters(ParametersInterceptor.java:288)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:199)
Thank you.
Try
<a href="ManufacturerProducts.action?manufId=<s:property value='manufId'/>&mName=<s:property value='manufName'/>">
<img src="<s:property value='manufLogo'/>" alt="<s:property value='manufName'/>" />
</a>
or
<a href="ManufacturerProducts.action?manufId=${manufId}&mName=${manufName}">
<img src="${manufLogo}" alt="${manufName}" />
</a>
or
<s:url id="urlId" action="ManufacturerProducts.action">
<s:param name="manufId" value="manufId" />
<s:param name="mName" value="manufName" />
</s:url>
<a href="${urlId}">
<img src="${manufLogo}" alt="${manufName}" />
</a>
or (better)
<s:a action="ManufacturerProducts.action">
<s:param name="manufId">${manufId}</s:param>
<s:param name="mName">${manufName}</s:param>
<img src="${manufLogo}" alt="${manufName}" />
</s:a>
or (better)
<s:a action="ManufacturerProducts.action">
<s:param name="manufId" value="manufId" />
<s:param name="mName" value="manufName" />
<img src="${manufLogo}" alt="${manufName}" />
</s:a>
One more alternatove
<a href="javascript:loadvalue()">
<img src="<s:property value='manufLogo'/>" alt="<s:property value='manufName'/>" />
</a>
javascript
function loadvalue(){
var param=encodeURI("manufId=<s:property value='manufId'/>&mName=<s:property value='manufName'/>");
window.location="ManufacturerProducts.action?"+param;
}
精彩评论