我是使用 spark java 构建 Web 应用程序的新手。
我正在尝试使用“之前”过滤器,但出现以下错误。请帮忙。我在下面粘贴了我的代码。Bootstrap 是我的类具有主要方法。
错误:“BootStrap 类型之前的方法未定义”
public class BootStrap {
public static void main(String[] args) throws Exception {
ipAddress("localhost");
port(3003);
staticFileLocation("/public/html");
before((request, response) -> {
String user = request.queryParams("user");
String password = request.queryParams("password");
String dbPassword = usernamePasswords.get(user);
if (!(password != null && password.equals(dbPassword))) {
halt(401, "You are not welcome here!!!");
}
});
}