将字符串设置为可点击的网址 [英] Set String to clickable URL

查看:114
本文介绍了将字符串设置为可点击的网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我能够将普通文本中的属性更改为URL(超链接),因此用户可以点击它并重定向到另一个页面。



基本上,我从servlet 获得的属性是www.stackoverflow.com,但是它是纯文本,所以我的问题是如何将其更改为可点击的链接

>

那里的任何专家知道如何设置它?

 <%@ page language =javacontentType =text / html ; charset = UTF-8pageEncoding =UTF-8%> 
<%@ page import =java.util。*%>
<!DOCTYPE html PUBLIC - // W3C // DTD HTML 4.01 Transitional // ENhttp://www.w3.org/TR/html4/loose.dtd\">
< html>
< head>
< link rel =stylesheettype =text / csshref =2nd.css>
< meta http-equiv =Content-Typecontent =text / html; charset = UTF-8>
< title>超级搜寻< /标题>
< / head>
< body>
< h4>以下是结果< / h4>
<%
String testresults =(String)request.getAttribute(testresults);
out.print(+ testresults);
%>
< br>
< br>
<%
String testcontent =(String)request.getAttribute(testcontent);
out.print(+ testcontent);
%>
< / body>
< / html>


解决方案

;> 标记。

类似于

 < a href =<%= testresults%>><%= testresults%>< / a> 

问候


Am I able to change one the attribute from normal text become an URL(hyperlink) so user will be able to click on it and redirect to another page.

Basically the attribute that I get from servlet is www.stackoverflow.com but is in plain text so my question is how do I change it to a clickable link?

Any expert out there know how to set it? Thank you so much and have a nice day!

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="java.util.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <link rel="stylesheet" type="text/css" href="2nd.css">
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>THE SUPER SEARCH</title>
    </head>
    <body>
        <h4>Here's the following results</h4>
        <%
            String testresults=(String)request.getAttribute("testresults");
            out.print("" + testresults);
        %>
        <br>
        <br>
        <% 
            String testcontent=(String)request.getAttribute("testcontent");
            out.print("" + testcontent);
        %>
    </body>
</html>

解决方案

Put it inside an <a> tag.
Something like

<a href="<%=testresults%>"><%=testresults%></a>

Regards

这篇关于将字符串设置为可点击的网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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