$("#btn-form-login").click(function(){
var uname = $("#uname").val();
console.log(uname);
$.ajax({
url :"${base}/assest_login/sendlogin",
data:{city:uname},
type : "post",
dataType:"json",
async : false, //同步执行
succese : function(result) {
//将返回数据同步到资产中
alert("成功");
$("#dialog-tbzc").dialog().close();
//关闭对话框后加载下页面
window.location.reload();
}
});
});
import java.util.Map;
import org.apache.log4j.Logger;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Fail;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.POST;
import org.nutz.mvc.annotation.Param;
import com.venustech.tsoc.cupid.annotation.Log;
import com.venustech.tsoc.cupid.spsm.service.SpsmService;
@IocBean
@At("/assest_login")
@Fail("error")
public class SpsmController {
private Logger logger = Logger.getLogger(SpsmController.class) ;
@Inject("refer:spsmService")
private SpsmService service;
/* @POST
@At("/sendlogin")
@Ok("json")
@Log(isEnabled=false)
public Map<String,String> sendLogin(HttpServletRequest request, @Param("username") String uname ,@Param("password") String passwd) {
System.out.println(uname);
if(!uname.isEmpty() && !passwd.isEmpty()) {
service.login(uname,passwd);
}
HashMap<String, String> map = new HashMap<>();
return map;
}*/
@At("/sendlogin")
@Ok("json")
@POST
@Log(isEnabled=false)
public Map<String,String> reqLogin(@Param("city") String city) {
if(!city.isEmpty()) {
Map<String, String> map = service.reqLogin(city);
return map;
}else{
logger.error("请求异常。。。。。。");
return null;
}
}
}