jstl c下的Angular js ng-model:param值

时间:2016-01-13 02:09:07

标签: javascript angularjs jstl

如何在“”下看到{{angularJSvalue}}? h2部分工作正常,但我不知道如何把它放在“”标志下。这就是我想要过滤按钮:...students.html?fname=%7b%7bfilterName%7d%7d

<input type = "text" ng-model="filterName"/>
<h2>{{filterName}}</h2>
<a class="btn btn-default" href=
    <c:url value="students.html">
         <c:param name="fname" value="{{filterName}}"/>
    </c:url>
>Filter</a>

编辑: 我需要保留c:url,因为我想将一些当前的params放在新的url

<input type = "text" ng-model="filterName"/>
<h2>{{filterName}}</h2>
<a class="btn btn-default" href=
    <c:url value="students.html">
         <c:param name="fname" value="{{filterName}}"/>
         <c:param name="pageNumber" value="1"/>
         <c:forEach items="${param}" var="entry">
            <c:if test="${entry.key == 'itemsOnPage'}">
                <c:param name="${entry.key}" value="${entry.value}" />
            </c:if>
        </c:forEach>
>Filter</a>

1 个答案:

答案 0 :(得分:0)

此问题与双引号括起来的值无关,但由于对客户端和服务器端之间差异的理解不正确。

实质上,您的AngularJS filterName值仅存在于客户端上,但您尝试使用JSP(或类似的服务器端技术)在服务器上呈现它。

主要问题是:为什么需要使用服务器端构造来呈现URL?为什么不使用Angular,例如与ngHref

<a class="btn btn-default" ng-href="students.html?fname={{filterName}}"/>