gpt4 book ai didi

spring - 何时使用 Spring :url tag?

转载 作者:行者123 更新时间:2023-12-04 20:45:27 25 4
gpt4 key购买 nike

我认为 huge manipulations with URL 的问题是一样的(即为什么?)。人们只是从头开始重建 URL。

如果 UI 开发人员看到以下所有内容,它是否会妨碍应用程序的可见性:

<link href="${some_url_possibly_not_named_logically_i_e_karamba1243}/less/bootstrap.less"/> 

我只是不明白使用这些标签的用例,我为什么要这样做?
如何使用 spring:url 标记改进此示例代码段?它是否仅用于删除 URL 的重复部分?
<div id="header">
<ul>
<li><a href="/futfarm/home/">Home</a></li>
<li><a href="/futfarm/person/myProfile/">My Profile</a></li>


<sec:authorize access="hasRole('ROLE_Coach')">

<li><a href="/futfarm/coach/training/viewbank">Training</a></li>
</sec:authorize>

<sec:authorize access="hasRole('ROLE_Player')">

<li><a href="/futfarm/player/training/viewbank">Training</a></li>
</sec:authorize>


<sec:authorize access="hasRole('ROLE_Manager')">

<li><a href="/futfarm/manager/administration">Administration</a></li>
</sec:authorize>
</ul>
</div>

或者主要的问题是,如果在另一个 .jsp 中使用相同的 URL,我们可以只获取一个变量,但是这个标签又是特定于 jsp 范围的,因此其他页面无法使用它。一世
传统方法有什么问题?有没有除了 spring:url 之外我什么都不能使用的例子。

这正是每个人都使用它的情况之一,没有人解释(甚至谷歌 - 提供 super url 重建案例),每个人都很高兴,除了我,感到困惑和愚蠢:-)

最佳答案

当您需要在生成的 URL 中包含动态组件(例如 /app/resources/{name} )以及需要确保这些 URL 组件(例如 {name} 如上所述)被正确转义时,请使用它。看 here了解更多信息。

另请注意,您可以使用全局属性,例如<spring:url />跨多个 JSP 标记。看看setExposedContextBeanNames(String[]) here .

关于spring - 何时使用 Spring :url tag?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18477406/

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