在春季启动时重定向

时间:2019-04-27 09:25:41

标签: spring-boot spring-mvc web

我在spring-boot上写了登录系统,但是当我要登录时出现了问题,spring从表单中获取了登录名和密码,但是无法重定向到帐户页面。

Controller

Error

function Person (argument_name, argument_age) {
  this.name = argument_name;
  this.age = argument_age;
  this.changeName = function (argument_change_name) {
    this.name = argument_change_name;
  }
}

let p1 = new Person ("John", 30);
p1.changeName ("Jane");
console.log(p1);

3 个答案:

答案 0 :(得分:0)

首先,您应该使用from concurrent import futures MAX_WORKERS = 20 def download_one(c): import time time.sleep(100) def download_many(): executor = futures.ThreadPoolExecutor(MAX_WORKERS) res = executor.map(download_one, [1,2,3,4],timeout=5) print(list(res)) return len(list(res)) download_many() 前缀:

from concurrent import futures
MAX_WORKERS = 20

def download_one(c):
    import time
    time.sleep(100)


def download_many():
    with futures.ThreadPoolExecutor(MAX_WORKERS) as executor:
        res = executor.map(download_one, [1,2,3,4],timeout=5)
        print(list(res))

    return len(list(res))

download_many()

此处有更多信息:https://www.baeldung.com/spring-redirect-and-forward

第二件事-从您的屏幕截图中-我看到您的控制器配置为处理redirect请求,但是您从浏览器发送了//... return "redirect:/admin/account"; // ... return "redirect:/student/account"; 请求: localhost:8080 / user / login ?login = isi&password = test

答案 1 :(得分:0)

首先,您需要将@PostMapping替换为@RequestMapping,以便同时允许POSTGET请求。您的登录请求是POST请求,而重定向是GET请求。 其次,spring boot中的重定向以redirect:/为前缀。因此,您的重定向代码应如下所示:

return "redirect:/admin/account"

答案 2 :(得分:0)

我已经更正,但是重定向到管理页面时出现问题,但是无法显示相应页面的内容