Javascript 我尝试从登录表单中获取信息,并将其更改为id
我有一个html的登录页面,我在那里得到用户名,密码和类型 当我登录到帐户时,我需要从用户注册时获得的id中查找帐户详细信息,但每次我收到此消息时,它都无法从“'java.lang.String'转换为所需的类型'long'”;我怎样才能解决这个问题? 我的登录方法返回long,这是id类型 代码如下:Javascript 我尝试从登录表单中获取信息,并将其更改为id,javascript,java,html,Javascript,Java,Html,我有一个html的登录页面,我在那里得到用户名,密码和类型 当我登录到帐户时,我需要从用户注册时获得的id中查找帐户详细信息,但每次我收到此消息时,它都无法从“'java.lang.String'转换为所需的类型'long'”;我怎样才能解决这个问题? 我的登录方法返回long,这是id类型 代码如下: public class LoginController { @Autowired LoginServiceImpl loginService; @GetMappin
public class LoginController {
@Autowired
LoginServiceImpl loginService;
@GetMapping("/login/{userName}/{password}/{clientType}")
public long Login(@PathVariable("userName") String userName,@PathVariable("password") String password,
@PathVariable("clientType") ClientType clientType)throws CustomException {
return loginService.login(userName, password, clientType);}
public long login(String userName, String password, ClientType clientType) throws CustomException {
if(clientType.equals(ClientType.ADMIN)) {
adminService.login(userName, password, clientType);
System.out.println("admin loged in");
}
else if(clientType.equals(ClientType.COMPANY)) {
Company companyLogin = companyRepository.findByCompName(userName);
companyService.login(userName, password, clientType);
System.out.println("company loged in");
return companyLogin.getId();
}
else if(clientType.equals(ClientType.CUSTOMER)) {
customerService.login(userName, password, clientType);
System.out.println("customer loged in");
}
else {
System.out.println("login didnt execute");
}
return 0;
}
$scope.submit=function(){
$http.get("http://localhost:8080/rest/api/login/" + $scope.username +"/" + $scope.password + "/" + $scope.cType).then(
function(response){
$scope.login = response.data;
switch ($scope.cType){
case "COMPANY":
window.location.assign("http://localhost:8080/rest/api/company.html")
break;
$scope.hideAllTables();
$scope.welcomePage = true;
// $scope.MainMenu = true;
$http.get('http://localhost:8080/rest/api/company.html/comanyDetailes/' + compny).then(function(response) {
$scope.company = response.data;
$scope.welcomePage = true;
}, function(error) {
alert('operation failed ', error.data);
});