Java Spring引导卡在初始化Spring DispatcherServlet时
我是SpringBoot新手,我正在尝试开发一个用户注册和登录系统 在Eclipse上运行程序后,它成功启动<代码>在2.318秒内启动CustomerApplication(JVM运行时间为2.938) 但问题是,当我试图从浏览器访问页面时,它会一直加载我的Thymeleaf页面 控制台上显示:Java Spring引导卡在初始化Spring DispatcherServlet时,java,spring-boot,servlets,thymeleaf,Java,Spring Boot,Servlets,Thymeleaf,我是SpringBoot新手,我正在尝试开发一个用户注册和登录系统 在Eclipse上运行程序后,它成功启动在2.318秒内启动CustomerApplication(JVM运行时间为2.938) 但问题是,当我试图从浏览器访问页面时,它会一直加载我的Thymeleaf页面 控制台上显示:初始化Spring DispatcherServlet'DispatcherServlet' Myuseraccountcontroller.javacontroller类: @Controller publi
初始化Spring DispatcherServlet'DispatcherServlet'
Myuseraccountcontroller.java
controller类:
@Controller
public class UserAccountController {
@Autowired
private CustomerRepository userRepository;
@Autowired
private ConfirmationTokenRepository confirmationTokenRepository;
@Autowired
private EmailSenderService emailSenderService;
@RequestMapping(value="/register", method = RequestMethod.GET)
public ModelAndView displayRegistration(ModelAndView modelAndView, Customer user)
{
modelAndView.addObject("user", user);
modelAndView.setViewName("register");
return modelAndView;
}
@RequestMapping(value="/register", method = RequestMethod.POST)
public ModelAndView registerUser(ModelAndView modelAndView, Customer user)
{
Customer existingUser = userRepository.findByEmailIdIgnoreCase(user.getEmailId());
if(existingUser != null)
{
modelAndView.addObject("message","This email already exists!");
modelAndView.setViewName("error");
}
else
{
userRepository.save(user);
ConfirmationToken confirmationToken = new ConfirmationToken(user);
confirmationTokenRepository.save(confirmationToken);
SimpleMailMessage mailMessage = new SimpleMailMessage();
mailMessage.setTo(user.getEmailId());
mailMessage.setSubject("Complete Registration!");
mailMessage.setFrom("rukshan033@gmail.com");
mailMessage.setText("To confirm your account, please click here : "
+"http://localhost:8082/confirm-account?token="+confirmationToken.getConfirmationToken());
emailSenderService.sendEmail(mailMessage);
modelAndView.addObject("emailId", user.getEmailId());
modelAndView.setViewName("successfulRegisteration");
}
return modelAndView;
}
@RequestMapping(value="/confirm-account", method= {RequestMethod.GET, RequestMethod.POST})
public ModelAndView confirmUserAccount(ModelAndView modelAndView, @RequestParam("token")String confirmationToken)
{
//System.out.println("tokkon issa0: "+confirmationToken);
ConfirmationToken token = confirmationTokenRepository.findByConfirmationToken(confirmationToken);
if(token != null)
{
//System.out.println("tokkon issa1: "+token);
Customer user = token.getCustomer();
//Customer user = userRepository.findByEmailIdIgnoreCase(token.getCustomer().getEmailId());
user.setEnabled(true);
userRepository.save(user);
modelAndView.setViewName("accountVerified");
}
else
{
//System.out.println("tokkon issa2: "+token);
modelAndView.addObject("message","The link is invalid or broken!");
modelAndView.setViewName("error");
}
return modelAndView;
}
@RequestMapping(value="/login", method= {RequestMethod.GET, RequestMethod.POST})
public ModelAndView login(ModelAndView modelAndView, @RequestParam("emailID")String email, @RequestParam("password")String password)
{
Customer user = userRepository.findByEmailIdIgnoreCase(email);
if(user == null) {
modelAndView.addObject("message1","Invalid E-mail. Please try again.");
modelAndView.setViewName("login");
}
/*else if (user != null && user.getPassword()!=password) {
modelAndView.addObject("message1","Incorrect password. Please try again.");
modelAndView.setViewName("login");
}
else if (user != null && user.getPassword()==password && user.isEnabled()==false) {
modelAndView.addObject("message1","E-mail is not verified. Check you inbox for the verification link.");
modelAndView.setViewName("login");
}*/
else if (user != null && user.getPassword()==password) { //////////////////////////////////////////////////////////////
modelAndView.addObject("message1","Welcome! You are logged in.");
modelAndView.setViewName("customerAccount");
}
return modelAndView;
}
// getters and setters
public CustomerRepository getUserRepository() {
return userRepository;
}
public void setUserRepository(CustomerRepository userRepository) {
this.userRepository = userRepository;
}
public ConfirmationTokenRepository getConfirmationTokenRepository() {
return confirmationTokenRepository;
}
public void setConfirmationTokenRepository(ConfirmationTokenRepository confirmationTokenRepository) {
this.confirmationTokenRepository = confirmationTokenRepository;
}
public EmailSenderService getEmailSenderService() {
return emailSenderService;
}
public void setEmailSenderService(EmailSenderService emailSenderService) {
this.emailSenderService = emailSenderService;
}
}
我的register.html
thymileaf页面:
登记处
在或
0
-
-
登记表
名字
姓
出生日期
电话
电子邮件
街头
城市
地区
省
密码
确认密码
我接受使用条款和隐私政策。
现在注册
关于
Donec vitae purus nunc。Morbi faucibus erat坐在amet congue mattis旁边。我的朋友是福西布斯·乌尔纳,我的名字是埃拉特·艾库利斯·乌尔纳。整数交流扫描电镜
问题
问题
穿什么鞋
2018年10月21日
今年的趋势
2018年10月21日
2020-09-05 20:24:26.578 INFO 27384 --- [ main] c.O.customer.CustomerApplication : Starting CustomerApplication on LAPTOP-D72B23NQ with PID 27384 (C:\Users\User\Desktop\customer\target\classes started by User in C:\Users\User\Desktop\customer)
2020-09-05 20:24:26.579 INFO 27384 --- [ main] c.O.customer.CustomerApplication : No active profile set, falling back to default profiles: default
2020-09-05 20:24:27.468 INFO 27384 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-09-05 20:24:27.468 INFO 27384 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.36]
2020-09-05 20:24:27.575 INFO 27384 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
2020-09-05 20:24:27.687 INFO 27384 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2020-09-05 20:24:27.690 WARN 27384 --- [ main] com.zaxxer.hikari.util.DriverDataSource : Registered driver with driverClassName=com.mysql.jdbc.Driver was not found, trying direct instantiation.
2020-09-05 20:24:27.776 INFO 27384 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2020-09-05 20:24:27.849 WARN 27384 --- [ main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
Hibernate: alter table confirmation_token add constraint FKpitnf1t12om2w2btrcd37gwpq foreign key (user_id) references customer (user_id)
2020-09-05 20:24:28.657 INFO 27384 --- [ main] c.O.customer.CustomerApplication : Started CustomerApplication in 2.318 seconds (JVM running for 2.938)
2020-09-05 20:24:37.951 INFO 27384 --- [nio-8082-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'