我正在尝试使用Spring Framework,RESTful Web服务和Jersey实现从我的数据库验证用户记录.
我使用的是MySQL v5.6.0,Eclipse Galileo,Apache tomcat v6.0
UserAccessWS.java
@Path("/user")
@Service
public class UserAccessWS {
@Autowired
private IUserService userService;
private static Logger LOGGER = Logger.getLogger(UserAccessWS.class);
@POST
@Path("/validateUser")
@Produces({ MediaType.APPLICATION_JSON })
public String getValidateUser(@Context HttpServletRequest request,
@FormParam("userName") String userName,
@FormParam("password") String password) throws JSONException {
LOGGER.info("getValidateUser method");
Users users = new Users();
users.setUserName(userName);
users.setPassword(password);
List<Users> userList = new ArrayList<Users>();
userList = userService.validateUser(users);
JSONObject userInfo = new JSONObject();
userInfo.put("authorize", true);
return userInfo.toString();
}
@POST
@Path("/login")
@Produces({ MediaType.APPLICATION_JSON })
public String userLogin(
@FormParam("userName") …
Run Code Online (Sandbox Code Playgroud)