假设我得到的网址是这样的 https://www.youtube.com/watch?v=kXYiU-6ren">
gpt4 book ai didi

java - 如何将 YouTube 链接设为嵌入?

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

<%
String song = request.getParameter("songname");
String band = request.getParameter("band");
String url = request.getParameter("url");
%>
<div align="center">
<br><br> <% out.print(band + " - " + song); %><br><br>
<iframe width="560" height="315" src="<%out.print(url);%>" frameborder="0" allowfullscreen></iframe>
</div>
<%
%>

假设我得到的网址是这样的 https://www.youtube.com/watch?v=kXYiU_JCYtU我想让它看起来像 https://www.youtube.com/embed/kXYiU_JCYtU这样我就可以把它放在 src=""

最佳答案

您可以使用<a href="http://download.oracle.com/javase/6/docs/api/java/lang/String.html#replace%28java.lang.CharSequence,%20java.lang.CharSequence%29" rel="noreferrer noopener nofollow">replace()</a>方法:

<% out.print(url.replace("watch?v=", "embed/")); %>

关于java - 如何将 YouTube 链接设为嵌入?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30820979/

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