后台做个一个appLogin的方法
类是UserControl
@Controller
@RequestMapping("/user")
这个是登陆的代码
然后android中使用HttpUrlConnection方法
但是urlConnection.getResponseCode 的代码是400...
想咨询一下我的Url写的不对么?应该怎么写
还想问一下我的参数传值对不对
最后logcat总是在提示:
04-21 04:37:05.910 82-82/? D/: Socket deconnection
有没有大神可以给我看一下
类是UserControl
@Controller
@RequestMapping("/user")
这个是登陆的代码
@RequestMapping("/appLogin")
public String appLogin(
@ModelAttribute("command") Usera user,
@PathVariable String userName,
@PathVariable String password,
Model model,HttpSession session,HttpServletResponse response) throws IOException{
String loginResult = userDao.login(userName, password);
if (loginResult!=null&&loginResult!="error") {
session.setAttribute("loginInfo", loginResult);
//相应登陆成功的信息 通过response输出流输出
response.getOutputStream().write("登陆成功".getBytes());
return null;
}else{
response.getOutputStream().write("登陆失败".getBytes());
return "/loginPage";
}
}
然后android中使用HttpUrlConnection方法
String spec = "http://192.168.1.66:8080/graduation/user/appLogin";
URL url = new URL(spec);
HttpURLConnection urlConnection = (HttpURLConnection)url.openConnection();
但是urlConnection.getResponseCode 的代码是400...
想咨询一下我的Url写的不对么?应该怎么写
还想问一下我的参数传值对不对
String data = "name="+URLEncoder.encode(name,"UTF-8")+"&password="+URLEncoder.encode(password,"UTF-8");
最后logcat总是在提示:
04-21 04:37:05.910 82-82/? D/: Socket deconnection
有没有大神可以给我看一下