jquery调后台服务
来源:互联网 发布:颐和园结局 知乎 编辑:程序博客网 时间:2024/06/04 22:46
try {
final Map<String, Object[]> params = new HashMap<String, Object[]>();
params.putAll(req.getParameterMap());
String command=params.get("command")[0].toString();
String username=params.get("username")[0].toString();
String password=params.get("password")[0].toString();
String result = null;
ApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(this.getServletContext());
PropertyPlaceholderConfigurer propertyConfigurer = (PropertyPlaceholderConfigurer)ctx.getBean("propertyConfigurer");
BasicDataSource ds = (BasicDataSource)ctx.getBean("dataSource");
String dbdriver = ds.getDriverClassName();
String dburl = ds.getUrl();
String dbuser = ds.getUsername();
String dbpass = ds.getPassword();
userService = (UserService)ctx.getBean("userService");
//userDao = (UserDao)ctx.getBean("userDao");
//WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
//UserService userService = (UserService)ctx.getBean("userService");
User user = userService.getUserById(1);
if("login".compareTo(command)==0) {
result = userService.login(username, password);
}
resp.setContentType("application/json; charset=UTF-8");
resp.setStatus(HttpServletResponse.SC_OK);
resp.getWriter().print("{\"result\":\"" + result + "\"}");
} catch (IOException e) {
e.printStackTrace();
}
return;
}
<body>
登录名:<input type="text" id="username">
密码:<input type="password" id="password">
<button id="login">登陆</button>
</body>
/**
*
*/
/*jquery函数*/
(function($, window, document,undefined) {
function fun1() {
$("div").css("color", "red");
};
function login(name, password){
var data = {
username: name,
password: password
};
$.ajax( {
type : "POST",
url : "/cids/api?command=login&response=json",
data: data,
dataType: "json",
async: false,
success : function(data) {
if(data.result == "true"){
alert("登录成功!");
}
else{
alert("登录失败!");
}
if(data.session =="1234567890"){
alert("1234567890");
}
},
error :function(){
alert("网络连接出错!");
}
});
}
$(document).ready(function() {
$("#login").click(function() {
login($("#username").val(), $("#password").val());
});
})
})(jQuery, window, document);
- jquery调后台服务
- 后台服务
- 后台服务
- jQuery AJAX实现调用页面后台方法和web服务定义的方法
- jQuery.ajax与后台服务交互的几种类型使用示例
- jQuery AJAX实现调用页面后台方法和web服务定义的方法
- Linux 后台服务进程
- 编写后台服务程序
- Java后台服务程序设计
- Java后台服务程序设计
- tomcat 加入后台服务
- JS 后台服务调用
- Java 后台服务程序设计
- c# 后台服务
- 后台服务程序开发
- linux后台运行服务
- 使用后台服务 IntentService
- VC 后台服务程序
- github常见操作和常见错误!错误提示:fatal: remote origin already exists.
- Android开发也需要了解的TCP\IP和Http知识
- 取当前记录行的后一行记录和前一行记录lead()和lag()
- HDU
- 控制另一个程序里的数据窗口
- jquery调后台服务
- shiro 认证(一)
- Json与Xml对比
- build.gradle配置说明
- 神奇的where 语句
- Xilinx Zynq器件要点(2)
- Oracle学习网站总结
- EM算法原理和python简单实现
- Dagger2 进阶