我正在使用 Visual Studio Code 作为编辑器开发 TypeScript 2.4 版。我使用以下命令安装了带有 NPM 的 jQuery:
npm install --save @types/jquery
Run Code Online (Sandbox Code Playgroud)
然后我jquery module从GitHub下载了 的源代码。
registrationpage.ts文件代码如下:
import * as $ from 'jquery';
class Registration_Page {
txtuname: string;
Registration() {
$('#table').hide;
this.txtuname = ( <HTMLTextAreaElement> (document.getElementById('txtusername'))).value;
}
}
window.onload = () => {
$('#table').show;
var bttnLogin = document.getElementById('submit');
var obj = new Registration_Page();
bttnLogin.onclick = function () {
obj.Registration();
}
}
Run Code Online (Sandbox Code Playgroud)
代码index.html如下:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="registrationpage.js"></script>
</head> …Run Code Online (Sandbox Code Playgroud) 我在多线程环境中使用 Spring Redis 模板。一个线程将数据保存到 Redis 中,另一个线程(调度程序)从中获取数据。JedisConnectionFactory 用于 redis 模板。以下是获取redis连接的代码片段:
JedisConnectionFactory jedisConnectionFactory() {
JedisConnectionFactory jedisConnectionFactory = null;
try {
RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration(hostName,
port);
jedisConnectionFactory = new JedisConnectionFactory(redisStandaloneConfiguration);
} catch (RedisConnectionFailureException e) {
LOGGER.error("Connection break with redis " + e.getMessage());
}
return jedisConnectionFactory;
}
/**
* Redis template.
*
* @return the redis template
*/
@Bean
public RedisTemplate<String, Object> redisTemplate() {
final RedisTemplate<String, Object> template = new RedisTemplate<String, Object>();
template.setConnectionFactory(jedisConnectionFactory());
template.setValueSerializer(new GenericToStringSerializer<Object>(Object.class));
template.setEnableTransactionSupport(true);
return template;
}
Run Code Online (Sandbox Code Playgroud)
redis模板的实例是通过构造函数自动连线获取的,如下:
@Autowired
public A(RedisTemplate<String, …Run Code Online (Sandbox Code Playgroud)