gpt4 book ai didi

java - 将 Angular js 与 taglib 结合使用

转载 作者:行者123 更新时间:2023-12-01 15:10:14 25 4
gpt4 key购买 nike

我正在使用 Stripes MVC 文本标签,但如果我向其中添加 Angular 的 ng-model,则会出现异常,因为 taglib 显然不支持该属性。有人知道处理这种情况的最佳做法吗?

<s:text name="name" ng-model="yourName" />

最佳答案

我对 Stripe 的标签库不是很熟悉,但是从他们的文档中我可以看到 ( http://www.stripesframework.org/display/stripes/Tag+Library+Doc ) Stripes MVC 确实包含了一个 tld 版本,您可以在其中使用所谓的“动态属性” :

However with the advent of AJAX and JavaScript libraries it is sometimes desirable to use non-HTML attributes in HTML tags. For the reasons outlined above Stripes includes two slightly different TLDs that can be used. The standard one does not allow dynamic attributes in HTML tags and should be used in most cases. The second one allows dynamic attributes. It is possible (even recommended) to use both TLDs in one page. Doing so will allow the standard library to be used where possible, and the dynamic attribute one only where absolutely necessary. E.g.:

<%@ taglib prefix="s" uri="http://stripes.sourceforge.net/stripes.tld" %>
<%@ taglib prefix="d" uri="http://stripes.sourceforge.net/stripes-dynattr.tld" %>

<s:form action="/my/NewsSearch.action">
<s:text name="keywords"/>
<d:text name="publicationDate" dojoType="calendar"/>
<s:submit name="search"/>
</s:form>

所以我想您应该简单地导入 tld 的“动态”版本并像这样使用它:

<%@ taglib prefix="d" uri="http://stripes.sourceforge.net/stripes-dynattr.tld" %>

<d:text name="name" ng-model="yourName" />

关于java - 将 Angular js 与 taglib 结合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12427690/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com