这是前端的mui.ajax
mui.ajax("http://192.168.151.1:8080/user/registerOrLogin",{
data:{
userName:username.value,
password:password.value,
cid:cid
},
dataType:'json',//服务器返回json格式数据
type:'post',//HTTP请求类型
timeout:5000,//超时时间设置为10秒;
headers:{'Content-Type':'application/json'},
success:function(data){
//服务器返回响应,根据响应结果,分析是否登录成功,如果为fail代表失败了,输出失败原因;
if(data.status=="fail")
{
app.showToast(data.data.errMsg,"error");
}
else
{
app.setUserGlobalInfo(data.data);
mui.openWindow("index.html","index.html");
}},
error:function(xhr,type,errorThrown){
//异常处理;
console.log("异常:"+type+errorThrown+xhr);
}
});
这是后端的接口
@RestController("user")
@RequestMapping("user")
public class UserController extends BaseController {
@Autowired
private UserService userService;
@RequestMapping("/registerOrLogin")
public CommonReturnType register(@RequestParam("userName") String userName,
@RequestParam("password") String password,
@RequestParam("cid") String cid) throws Exception{
一直连接不上