springboot

更新时间: 试题数量: 购买人数: 提供作者:

有效期: 个月

章节介绍: 共有个章节

收藏
搜索
题库预览
完成springboot入门案例。
注:(1.不需要编写配置文件和maven文件 2.主程序名称为HelloApplication,控制器为
HelloController )。
方式一:
@Controller( )
@SpringBootApplication ( )
@Configuration( )
Public class HelloApplication {( )@RequestMapping( )( )
@ResponseBody( )
Public String hello( ) {( )
Return "hello world!";( )
}
Public static void main(String[] args) {( )
SpringApplication.run(HelloApplication.class, args);( )
}
}
Springboot登录拦截器
Public class LoginHandlerInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
Object user = request.getSession( ).getAttribute( );
if (user == null){
request.setAttribute( );
request.getRequestDispatcher( ).forward( );
return false;
}else {
return true;
}
}
}
使用SpringBoot后台技术,编写一个接收前台ajax请求的程序( )。程序中的方法要接收一个String username,方法的逻辑是:如果username的值是aa或bb则返回页面"成功"字符串,否则返回"失败"字符串。( )
Package com.example.controller;
@RestController
@RequestMapping(" /Ajax1Controller")
Public class Ajax1Controller {
@RequestMapping( )
Public String ajax(String username){
If( )||"bb".equals( )){
Return "成功";
}else{
Return "失败";
}
}
}
Https://www.kaoshibao.com/online/?paperId=10989506&practice=&modal=2&is_recite=&qtype=&text=%E9%9A%8F%E6%9C%BA%E7%BB%83%E4%B9%A0&sequence=0&is_collect=1&is_vip_paper=0
1 2