简体   繁体   English

JSP 未终止<s:a>使用嵌套 OGNL 标记

[英]JSP Unterminated <s:a> Tag With Nested OGNL

I have some OGNL I am using to populate the href element of an <s:a> to a dynamically produced URL, handled by the Google UserService.我有一些 OGNL 用于将<s:a>的 href 元素填充到动态生成的 URL,由 Google UserService 处理。

<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<c:set var="requestUri" value="%{#context['com.opensymphony.xwork2.dispatcher.HttpServletRequest'].requestURI}" />
<s:a href="%{#action.userService.createLoginURL("<c:out value="${requestUri}"/>");}">Sign in</s:a>

However, I am getting an error saying the <s:a> tag is unterminated.但是,我收到一条错误消息,指出<s:a>标记未终止。 I have tried escaping inner speechmarks, and using single quotes but so far I have always been greeted with the same error message.我曾尝试转义内部语音标记,并使用单引号,但到目前为止,我一直收到相同的错误消息。

(11,71) Unterminated &lt;s:a tag

I can't for the life of me see what is wrong.我这辈子都看不出哪里出了问题。 Maybe someone with better eyes for the language will see something I cannot.也许对语言有更好眼光的人会看到我看不到的东西。

You cannot use JSP tags in Struts tag's attributes, but you can use OGNL there.你不能在 Struts 标签的属性中使用 JSP 标签,但你可以在那里使用 OGNL。

Also note, that you can use OGNL only in Struts tag's attributes.另请注意,您只能在 Struts 标签的属性中使用 OGNL。 And in most cases OGNL is executed once on the server, you shouldn't use nested OGNL or whatever you call it.并且在大多数情况下 OGNL 在服务器上执行一次,您不应该使用嵌套的 OGNL 或任何您称之为的东西。 May be this question will show you how to use you called nested OGNL .可能这个问题会告诉你如何使用你调用的嵌套 OGNL

<s:set var="requestUri" value="%{#context['com.opensymphony.xwork2.dispatcher.HttpServletRequest'].requestURI}" />
<s:a href="%{#action.userService.createLoginURL(#requestUri)}">Sign in</s:a>

Ah ok problem solved.啊好问题解决了。 Turns out the c:out wasn't needed to output the value of requestUri.结果证明不需要 c:out 来输出 requestUri 的值。 It could simply be left as-is to be evaluated with the rest of the expression它可以简单地保持原样,用其余的表达式进行评估

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM