识别h:outputText中的链接 [英] Recognize links in h:outputText

查看:74
本文介绍了识别h:outputText中的链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用< h:outputText> 标签组件显示一些文本。有这样的要求,如果文本包含一个URL,即 http // example.com.co ,我需要显示它作为链接。

I need to show some text using <h:outputText> tag component. There is this requirement that if the text contains an URLs i.e. http//example.com.co, I need show it as a link.

例如,如果用户输入 Yo quiero www.google.com ,我需要显示 Yo quiero www.google.com

For example, if user enters Yo quiero www.google.com I need to show Yo quiero www.google.com

推荐答案

在您的字符串上进行正则表达式替换。你可以使用 string.replaceAll()来实现这个功能。

You need a function which does a regular expression replace on your string. You can use string.replaceAll() for this.

您可以创建一个自定义的jsf标签(

You have multiple options to place this function.


  1. a href =http://jdevelopment.nl/simple-java-based-jsf-custom-component/ =nofollow noreferrer>示例)

  2. 您可以创建自定义el功能(示例

  1. You can create a method in your backing bean.
  2. You can create a custom jsf tag (example)
  3. You can create a custom el function (example)

没有1是最简单的实施imho。

No 1 is the easiest to implement imho.

这篇关于识别h:outputText中的链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆