【发布时间】:2016-10-24 15:34:12
【问题描述】:
下面是我的控制器类。
@Controller
public class BankController {
@Autowired
private CustomerService customerService;
@Autowired
private CustomerRepository customerRepository;
@RequestMapping(value="/login", method=RequestMethod.POST)
public String actionLogin(@RequestParam String email, @RequestParam String password, Model model){
List<Customer> byEmail = customerRepository.findByEmail(email);
Customer customer = byEmail.get(0);
if(BCrypt.checkpw(password, customer.getHashedPassword())){
model.addAttribute("customer", customer);
return "enterSiteView.html";
}
return "errorView.html";
}
我已将enterSiteView.html, errorView.html 保存在文档中给出的模板文件夹中。
当我单击登录按钮时,url 确实更改为http://localhost:9090/enterSiteView.html,但它显示错误。
Whitelabel Error Page
application has no explicit mapping for /error, so you are seeing this as a fallback.
Sun Oct 23 14:03:43 IST 2016
There was an unexpected error (type=Not Found, status=404).
No message available`
我的enterSiteView.html 中只有一条Hello World 文本。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Hello Earth</title>
</head>
<body>
</body>
</html>
登录页面:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Sign-Up/Login Form</title>
<link href='http://fonts.googleapis.com/css?family=Titillium+Web:400,300,600' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="form">
<ul class="tab-group">
<li class="tab active"><a href="#signup">Sign Up</a></li>
<li class="tab"><a href="#login">Log In</a></li>
</ul>
<div class="tab-content">
<div id="signup">
<h1>Sign Up for Free</h1>
<form action="/register" method="post">
<div class="top-row">
<div class="field-wrap">
<label>
First Name<span class="req">*</span>
</label>
<input type="text" required autocomplete="off"/>
</div>
<div class="field-wrap">
<label>
Last Name<span class="req">*</span>
</label>
<input type="text" required autocomplete="off"/>
</div>
</div>
<div class="field-wrap">
<label>
Email Address<span class="req">*</span>
</label>
<input type="email" required autocomplete="on"/>
</div>
<div class="field-wrap">
<label>
Set A Password<span class="req">*</span>
</label>
<input type="password" required autocomplete="off"/>
</div>
<button type="submit" class="button button-block"/>Get Started</button>
</form>
</div>
<div id="login">
<h1>Welcome Back!</h1>
<form action="/login" method="post">
<div class="field-wrap">
<label>
Email Address<span class="req">*</span>
</label>
<input type="email" id="email" name="email" required autocomplete="off"/>
</div>
<div class="field-wrap">
<label>
Password<span class="req">*</span>
</label>
<input type="password" id="password" name="password" required autocomplete="off"/>
</div>
<p class="forgot"><a href="#">Forgot Password?</a></p>
<button class="button button-block"/>
Log In</button>
</form>
</div>
</div><!-- tab-content -->
</div> <!-- /form -->
<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src="js/index.js"></script>
</body>
</html>
我在欢迎页面的静态中放置了 index.html。登录成功后,它应该重定向到所需的页面,而不是显示上述错误。
【问题讨论】:
标签: html spring spring-boot