java - 如何从 GWT 应用程序中的 URL 中删除哈希参数

标签 java url gwt

例如我有以下网址:

http://server:port/?parameter#token;ID=com.test;args=one&two&three

如果我想从 URL 中删除 ID 和参数而不重新加载页面,那么该怎么做。

注意:现在我正在使用下面的代码执行此操作,并且我正在寻找更好的选择

 PlaceRequest currentPlaceRequest = placeManager.getCurrentPlaceRequest();
        final String counts= currentPlaceRequest.getParameter( "args", null );
        String id = currentPlaceRequest.getParameter( "ID", null );
        String url = Window.Location.getHref();
        if( counts!= null && !counts.isEmpty() )
        {

            if( id!= null && !id.isEmpty() )
            {

                String counts= ";" + "args" + "=" + counts;
                String urlToReplace = url.replace( counts, "" );       
                Window.Location.replace( urlToReplace );
            }

最佳答案

您可以使用 History.getToken 检索当前 token ,对其进行处理,然后使用 History.newItem 设置它。请注意,根据您的设置(使用 Activities and Places 或 mvp4g/gwtp 等),这可能会触发应用程序中的另一个 Activity 。

关于java - 如何从 GWT 应用程序中的 URL 中删除哈希参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27016836/

相关文章:

java - 当使用 ObjectOutputStream/ObjectInputStream 传输自定义对象时,变量将被重置

javascript - 获取 javascript 中 url 设置的 php 变量的值

python - 当同一个项目中有多个应用程序时,如何在 django 中设置 url?

java - 在使用 AsyncDataProvider 创建的 GWT 项目 CellTable 中,未显示

java - GWT + 应用引擎

java - JAXB 使用 Woodstox 解析器来提高性能?

java - 闰年计划

java - 使用递归检查整数的位数是否为偶数

arrays - 如何从 url 数组中获取单个 url?

java - 让 GWT 应用程序与本地客户端进程通信