小编Ram*_*tha的帖子

如何将数据推送到jsp而不是每2秒请求一次?

我想每2秒将数据推送到jsp,而客户端请求它.
我在这里使用Spring with Hibernate.
我正在显示谷歌地图标记,我想通过从数据库获取数据每2秒更新标记位置,但是我已经从数据库获取数据每2秒,但我无法将数据推送到此JSP.

   @Scheduled(fixedRate = 2000)
   public void getData(){
                    // TODO Auto-generated method stub
                    DeviceDetails deviceDetails = realTimeDataDAO.getDeviceDetails(deviceId);
                    System.out.println(deviceDetails);
                }
Run Code Online (Sandbox Code Playgroud)

我必须每2秒显示一些数据.谁能告诉我怎么做?

任何人都知道Comet Ajax Push技术,它会在这种情况下工作吗?

javascript java spring server-push google-maps-api-3

5
推荐指数
2
解决办法
1万
查看次数

如何删除java.util.Set中的最后一个元素?

我想删除这个集合的每个最后一个元素.

        Set<String> listOfSources = new TreeSet<String>();
        for(Route route:listOfRoutes){
            Set<Stop> stops = routeStopsService.getStops(route);
            for(Stop stop:stops)
               listOfSources.add(stop.getStopName());
         }
Run Code Online (Sandbox Code Playgroud)

这里我想从listOfSources中删除最后一个元素.

java collections

5
推荐指数
2
解决办法
1万
查看次数

Linkedin Api如何通过人物搜索获取群组详细信息

我需要获得用户的组,

IN.API.Raw("/people-search:(people:(id,first-name,last-name,email-address,industry,summary,num-connections,headline,group-memberships:(group:(id)))?first-name=ramesh&last-name=kotha&count="+25).result(function(result, metadata) {
//got the details here
}
Run Code Online (Sandbox Code Playgroud)

当我使用result.values [0] .person.groupMembership.group.id时,它表示未定义.如何获取用户的组.

javascript linkedin linkedin-jsapi

5
推荐指数
1
解决办法
1104
查看次数

spring security oauth2 java config - 处理程序调度失败;嵌套异常是 java.lang.StackOverflowError

在 java config 中使用 OAuth2 配置 Spring Security,并且client_credentails流工作正常,但密码流抛出Handler dispatch failed;嵌套异常是 java.lang.StackOverflowError下面是日志信息

2016-10-10 23:19:08 DEBUG o.s.w.s.m.m.a.ExceptionHandlerExceptionResolver - Resolving exception from handler [public org.springframework.http.ResponseEntity<org.springframework.security.oauth2.common.OAuth2AccessToken> org.springframework.security.oauth2.provider.endpoint.TokenEndpoint.postAccessToken(java.security.Principal,java.util.Map<java.lang.String, java.lang.String>) throws org.springframework.web.HttpRequestMethodNotSupportedException]: org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.StackOverflowError

这是我的配置文件:

授权服务器配置.java

@Configuration
@EnableAuthorizationServer
public class AuthorizationServerConfiguration extends AuthorizationServerConfigurerAdapter {

    @Autowired
    DataSource dataSource;

    @Autowired
    private UserDetailsService userDetailsService;

    @Autowired
    @Qualifier("authenticationManagerBean")
    private AuthenticationManager authenticationManager;

    @Override
    public void configure(
      AuthorizationServerSecurityConfigurer oauthServer) 
      throws Exception {
        oauthServer
          .tokenKeyAccess("permitAll()")
          .checkTokenAccess("isAuthenticated()");
    }

    @Override
    public void configure(ClientDetailsServiceConfigurer clients) …
Run Code Online (Sandbox Code Playgroud)

spring spring-mvc spring-security spring-security-oauth2 spring-java-config

5
推荐指数
1
解决办法
1万
查看次数

使用Spring社交集成定制Spring Security OAuth2

自定义Spring安全OAuth2工作正常,现在想添加Spring Social集成(facebook登录,google登录等),当用户点击Facebook登录(用户不提供任何用户名/密码)时,Facebook会返回access_token,但是这个access_token我们不能用来查询我的应用程序web服务,为了得到我的应用程序access_token,我们需要传递用户名和密码,并使用grant_type作为密码.以下是我的配置文件

AuthorizationServerConfiguration.java

@Configuration
@EnableAuthorizationServer
public class AuthorizationServerConfiguration extends AuthorizationServerConfigurerAdapter {

    @Autowired
    DataSource dataSource;

    @Autowired
    @Qualifier("authenticationManagerBean")
    private AuthenticationManager authenticationManager;

    @Override
    public void configure(
            AuthorizationServerSecurityConfigurer oauthServer) 
                    throws Exception {
        oauthServer.allowFormAuthenticationForClients();
    }

    @Override
    public void configure(ClientDetailsServiceConfigurer clients) 
            throws Exception {
        clients.jdbc(dataSource);
    }

    @Bean
    @Primary
    public DefaultTokenServices tokenServices() {
        DefaultTokenServices tokenServices = new DefaultTokenServices();
        tokenServices.setSupportRefreshToken(true);
        tokenServices.setTokenStore(tokenStore());
        tokenServices.setAccessTokenValiditySeconds(86400000);
        tokenServices.setRefreshTokenValiditySeconds(86400000);
        return tokenServices;
    }


    @Override
    public void configure(AuthorizationServerEndpointsConfigurer endpoints) 
            throws Exception {
        endpoints
        .tokenServices(tokenServices())
        .authenticationManager(authenticationManager);
    }

    @Bean
    public TokenStore tokenStore() {
        return new JdbcTokenStore(dataSource);
    }
} …
Run Code Online (Sandbox Code Playgroud)

spring spring-security oauth-2.0 spring-security-oauth2

5
推荐指数
1
解决办法
1353
查看次数

如何在选择的原型javascript选择框中触发onchange事件?

我正在使用选择的原型选择框.现在我想在该选择框上触发onchange事件.这是选择原型的链接

这该怎么做.请帮我.

<script type="text/javascript" src="/js/Event.simulate.js"></script>
<script src="/js/prototype.js" type="text/javascript"></script>
<script src="/chosen/chosen.proto.js" type="text/javascript"></script>


<div class="side-by-side clearfix" style="margin-bottom:14px;">

        <select data-placeholder="Select Loacation"  class="chzn-select" tabindex="2" name="source">
          <option value="">Select Loacation</option>
          <option value="">option1</option>
          <option value="">option2</option>
        </select>
  </div>



Event.observe($(".chzn-select"),'change', function(){

//alert($(".chzn-select").chosen());

})
Run Code Online (Sandbox Code Playgroud)

javascript prototypejs prototype-chosen

4
推荐指数
2
解决办法
3万
查看次数

如何改变openlayers marker icon?

我在我的应用程序中使用Openlayers.

当我点击地图时,我已成功显示标记,但现在我想在点击它时更改标记图标,如何执行此操作.我没有找到任何方法marker.setIcon();

我真的很困惑.

map.events.register("click", map , function(e){
   var opx = map.getLonLatFromPixel(e.xy) ;
   var marker = new OpenLayers.Marker(opx);
   markers.addMarker(marker);
   marker.events.register("click", marker, function(e){
    //here i want to change the icon to some other 
    popup = new OpenLayers.Popup.FramedCloud("chicken",
                         marker.lonlat,
                         new OpenLayers.Size(200, 200),
                         "example popup",
                         null, true);

     map.addPopup(popup);
       }); 
    // here i want to change to default.
  });
Run Code Online (Sandbox Code Playgroud)

map openlayers

4
推荐指数
1
解决办法
2万
查看次数

如何通过spring mvc控制器通过ajax sumbit传递文件对象

我试图通过jquery ajax提交传递文件对象.
JSP代码

<div id="import-file">
        <input type="file" id="file"/>
        <table>
        <tr><td><input type="radio" name="type" value="csv"></td><td>CSV File</td></tr>
        <tr><td><input type="radio" name="type" value="excel"></td><td>Excel spread sheet</td></tr>
        <tr><td><input type="radio" name="type" value="tab"></td><td>Tab delimited</td></tr>
        </table>
</div>
Run Code Online (Sandbox Code Playgroud)

Java脚本代码

        var type = $($('input:radio:checked')[0]).val();
        var file = $("#file")[0].files[0];
        alert($("#file")[0].files[0].name);
        $.ajax({
            data :{
                "file" : file,
                "type" : type
            },
            type: "POST",
            url: "fileupload.htm",
            success: function(data){
                alert(data);
            },
            error:function(err){
                alert(err);
            }
        });
Run Code Online (Sandbox Code Playgroud)

最后这里是我的春季控制器代码:

@RequestMapping(value="fileupload.htm",method=RequestMethod.POST )
    public @ResponseBody String uploadFile(@RequestParam String type, @RequestParam("file") MultipartFile file){
        logger.info("file type : "+type + "file is "+file.toString());
        return …
Run Code Online (Sandbox Code Playgroud)

javascript jquery spring

4
推荐指数
1
解决办法
2万
查看次数

这个多线程Java代码如何工作?

鉴于此Java代码:

class Account {
        private Integer number = 0;
        public synchronized void setNumber(Integer number) {
            this.number = number;
        }

         public synchronized Integer getNumber() {
            return number;
        }
    }

    class Client extends Thread {
        Account account;
        public Client(Account account) {
            this.account = account;
        }
        public  void run() {
            for (int i = 1; i <= 1000; i++) {
            account.setNumber(account.getNumber() + 1);
             }
        }
    }

    public class Run {
        public static void main(String[] args) throws Exception {
            Account account = new Account(); …
Run Code Online (Sandbox Code Playgroud)

java multithreading

3
推荐指数
2
解决办法
175
查看次数

没有为jdbc找到合适的驱动程序:oracle:thin:@localhost:1521:运行Web应用程序时的XE

我遇到了奇怪的问题 No suitable driver found for jdbc:oracle:thin:@localhost:1521:XE

当我运行任何DAO的JUNIT测试用例时它插入正常.但是,当我在服务器中运行时,它正在给予No suitable driver found for jdbc:oracle:thin:@localhost:1521:XE

我已将ojdbc14.jar添加到WEB-INF/lib文件夹中.

这是jdbc.properties

jdbc.driverClassName=oracle.jdbc.driver.OracleDriver
jdbc.url=jdbc:oracle:thin:@127.0.0.1:1521:XE
jdbc.username=system
jdbc.password=pwd
Run Code Online (Sandbox Code Playgroud)

请帮我.

java oracle hibernate

2
推荐指数
1
解决办法
3万
查看次数

Google Map API信息框和for循环

希望能在这里得到一些帮助.我在数据库上有一些位置,我已经成功地将其放入一个成功绘制地图上标记的数组中.唯一的缺点是我想定制市场信息的外观,所以我使用信息框.

但是当我从我的数组中回显变量时,它回显到每个信息框的最后结果,并且我完全难以接受这个.

有人可以看看我的代码,看看哪里出了问题或指向正确的方向?

<script type="text/javascript" src="http://google-maps-utility-library-v3.googlecode.com/svn/tags/infobox/1.1.9/src/infobox.js"></script>
<script type="text/javascript" language="javascript">
// -- Location API -- //
infos = [];

function initialize() {
  var myOptions = {
    zoom: 3,
    center: new google.maps.LatLng(54.57206165565852, 12.48046875),
    mapTypeControl: false,
    mapTypeId: google.maps.MapTypeId.TERRAIN
  }
/* now inside your initialise function */
infowindow = new google.maps.InfoWindow({
content: "holding..."
});

  var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

  setMarkers(map, beaches);

}

/**
 * Data for the markers consisting of a name, a LatLng and a zIndex for
 * the order in which …
Run Code Online (Sandbox Code Playgroud)

google-maps google-maps-api-3

1
推荐指数
1
解决办法
3117
查看次数

为什么 zsh 没有正确执行我的正则表达式?

我开始使用zsh一段时间(使用此处描述的brew 安装)。

一切正常,但我注意到正则表达式运算符=~并没有真正起作用。


例如,如果我想从路径中提取 JSON 文件的文件名,我会在 bash 中得到正确的结果,但在 zsh 中却没有。

IE

bash -s 
[[ "/a/b/c/file.json" =~ ([[:alnum:]\-]+)\.json$ ]] && echo ${BASH_REMATCH[1]}
Run Code Online (Sandbox Code Playgroud)

工作并产生,file但在 zsh 中同样的事情只是打印一个空行。


有谁知道为什么以及如何解决这个问题?我是否必须以某种方式启用正则表达式支持?

regex zsh

1
推荐指数
1
解决办法
787
查看次数