JSP Unterminated <s:a> Tag With Nested OGNL

℡╲_俬逩灬. 提交于 2019-12-30 12:53:25

问题


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.

<%@ 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. 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.


回答1:


You cannot use JSP tags in Struts tag's attributes, but you can use OGNL there.

Also note, that you can use OGNL only in Struts tag's attributes. And in most cases OGNL is executed once on the server, you shouldn't use nested OGNL or whatever you call it. May be this question will show you how to use you called nested OGNL.

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



回答2:


Ah ok problem solved. Turns out the c:out wasn't needed to output the value of requestUri. It could simply be left as-is to be evaluated with the rest of the expression



来源:https://stackoverflow.com/questions/36119022/jsp-unterminated-sa-tag-with-nested-ognl

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!