Flask接口签名sign原理与实例代码浅析
307
2023-03-09
Spring boot搭建web应用集成thymeleaf模板实现登陆
Spring boot 搭建web应用集成了thymeleaf模板实现登陆
下面是pom.xml的配置
xmlns:xsi="http://w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> &wwZOcDJinHlt;java.version>1.7 <http://;groupId>org.springframework.boot
xmlns:xsi="http://w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
&wwZOcDJinHlt;java.version>1.7
<http://;groupId>org.springframework.boot
主入口main方法
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.web.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
/**
* Created by on 2016/12/8.
*/
@Configuration
@ComponentScan
@EnableAutoConfiguration
public class App extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
}
登陆页提交表单代码,
记住我
Controller 代码
package com.study.system.contrller;
import com.study.model.contrller.BaseContrller;
import com.study.model.po.User;
import com.study.system.services.UserServices;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
*
* 用户管理
* Created by on 2016/12/12.
*/
@Controller
@RequestMapping(value = "/user")
public class UserContrller extends BaseContrller {
@RequestMapping(value="/login",method= RequestMethod.POST)
public String login(User user){
try{
if(userServices.hasUser(user)){
return "redwwZOcDJinHirect:/user/index";
}else{
return "redirect:/";
}
}catch (Exception e){
logger.error("登陆失败:"+e,e);
}
return "redirect:/";
}
@RequestMapping(value="/index",method= RequestMethod.GET)
public String index(){
try{
}catch (Exception e){
logger.error("登陆失败:"+e,e);
}
return "page/index/index";
}
@Autowired
private UserServices userServices;
}
其中 UserServices 为业务接口。BaseContrller为自己封装的Controller基类。
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~