Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var user ={
- "id" : "1",
- "username" : "hello",
- "password" : "123456"
- };
- console.log(user);
- var response = $http.post("/login/signup",user);
- response.success(function (data) {
- alert("success");
- alert(data);
- });
- response.error(function (data) {
- alert("error");
- alert(data);
- });
- public class User {
- private long userID;
- private String username;
- private String password;
- public User(){
- }
- public User(long userID, String username, String password) {
- this.userID = userID;
- this.username = username;
- this.password = password;
- }
- public long getUserID() {
- return userID;
- }
- public void setUserID(long userID) {
- this.userID = userID;
- }
- public String getUsername() {
- return username;
- }
- public void setUsername(String username) {
- this.username = username;
- }
- public String getPassword() {
- return password;
- }
- public void setPassword(String password) {
- this.password = password;
- }
- }
- @Controller
- @RequestMapping(value = "/login")
- public class LoginController {
- @RequestMapping(value = "/signup",method = RequestMethod.POST)
- public String signUp(User user){
- String username = user.getUsername();// NULL!!
- System.out.println(username);
- return "login";
- }
- }
- @RequestMapping(value = "/signup",method = RequestMethod.POST)
- public String signUp(@RequestBody User user){
- String username = user.getUsername();
- System.out.println(username);
- return "login";
- }
- The server refused this request because the request entity is in a format not supported by the requested resource for the requested method.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement