我想每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技术,它会在这种情况下工作吗?
我想删除这个集合的每个最后一个元素.
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中删除最后一个元素.
我需要获得用户的组,
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时,它表示未定义.如何获取用户的组.
在 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
自定义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) 我正在使用选择的原型选择框.现在我想在该选择框上触发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) 我在我的应用程序中使用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) 我试图通过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) 鉴于此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) 我遇到了奇怪的问题 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)
请帮我.
希望能在这里得到一些帮助.我在数据库上有一些位置,我已经成功地将其放入一个成功绘制地图上标记的数组中.唯一的缺点是我想定制市场信息的外观,所以我使用信息框.
但是当我从我的数组中回显变量时,它回显到每个信息框的最后结果,并且我完全难以接受这个.
有人可以看看我的代码,看看哪里出了问题或指向正确的方向?
<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) 一切正常,但我注意到正则表达式运算符=~并没有真正起作用。
例如,如果我想从路径中提取 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 中同样的事情只是打印一个空行。
有谁知道为什么以及如何解决这个问题?我是否必须以某种方式启用正则表达式支持?
java ×4
javascript ×4
spring ×4
collections ×1
google-maps ×1
hibernate ×1
jquery ×1
linkedin ×1
map ×1
oauth-2.0 ×1
openlayers ×1
oracle ×1
prototypejs ×1
regex ×1
server-push ×1
spring-mvc ×1
zsh ×1