我有 Web 服务类,当被 HTML 登录页面调用时,它返回搜索的用户名,如下所示:
package com.paybyphone.dao;
import java.util.List;
import javax.ws.rs.Consumes;
import javax.ws.rs.FormParam;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.core.MediaType;
import com.paybyphone.model.MyDatabase;
@Path("/WebService")
public class LoginService {
@POST
@Path("/login")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public String login(@FormParam("userName") String userName) {
return getAllUsersList(userName.trim());
}
public String getAllUsersList(String userName) {
try {
// MyDatabase.createRegTable();
// MyDatabase.insertRecords();
MyDatabase rd = new MyDatabase();
List<UserVO> userList = null;
userList = MyDatabase.SelectAllRecords();
for (UserVO userVO : userList) {
String name = userVO.getUserName().trim();
if (name.equalsIgnoreCase(userName)) {
return "Logged in User:" + userName;
}
}
} catch (Exception e) {
System.out.println("error");
}
return "You are not a Valid User";
}
}
请!如果找到用户名,有人可以帮助我如何重定向到另一个 HTML 页面,而不是返回它。