如何为Web URL Java Spring创建Deeplink

发布于 2025-02-14 00:50:18 字数 125 浏览 0 评论 0原文

在我的基于Java的春季项目中,有一个我想通过消息发送给用户的Web URL。

但是,我正在寻找一种解决安全问题的解决方案,并将其发送给安全性和简短,而不是将长时间的链接转发给客户。

等待您的解决方案。谢谢。

In my Java spring-based project, there is a web url that I want to send to users via message.

But I'm looking for a solution to not give a security issue and send it both secured and short instead of forwarding a long link to customers.

Waiting for your solutions. Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

魄砕の薆 2025-02-21 00:50:18
public class Main {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
        UrlShortener url = new UrlShortener();
        System.out.println(url.decode("https://www.google.com"));
    }
}

public class UrlShortener {
    private static final String ALPHABET = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    private static final int    BASE     = ALPHABET.length();

    public static String encode(int num) {
        StringBuilder sb = new StringBuilder();
        while ( num > 0 ) {
            sb.append( ALPHABET.charAt( num % BASE ) );
            num /= BASE;
        }
        return sb.reverse().toString();   
    }

    public static int decode(String str) {
        int num = 0;
        for ( int i = 0; i < str.length(); i++ )
            num = num * BASE + ALPHABET.indexOf(str.charAt(i));
        return num;
    }   
}
public class Main {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
        UrlShortener url = new UrlShortener();
        System.out.println(url.decode("https://www.google.com"));
    }
}

public class UrlShortener {
    private static final String ALPHABET = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    private static final int    BASE     = ALPHABET.length();

    public static String encode(int num) {
        StringBuilder sb = new StringBuilder();
        while ( num > 0 ) {
            sb.append( ALPHABET.charAt( num % BASE ) );
            num /= BASE;
        }
        return sb.reverse().toString();   
    }

    public static int decode(String str) {
        int num = 0;
        for ( int i = 0; i < str.length(); i++ )
            num = num * BASE + ALPHABET.indexOf(str.charAt(i));
        return num;
    }   
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文