创建登录Controller 在controllers目录下创建ApplicationController类: package controllers import play.api.mvc._ class ApplicationController extends Controller { def login = Action { Ok(views.html.login("用户登录")) GET /doLogin controllers.ApplicationController.doLogin(userName: String, password: String) 加上数据验证 通常登录操作使用Post请求,所以我们调整一下routes: POST /doLogin controllers.ApplicationController.doLogin play.api.data.Forms._ class ApplicationController extends Controller { def login = Action { Ok
中添加springboot依赖: compile("org.springframework.boot:spring-boot-starter-web:1.5.8.RELEASE") 创建含main函数的AppLicationController WindCoder * Date: 2017-11-12 * Time: 22:30 下午 */ @Controller @EnableAutoConfiguration public class AppLicationController Spring-boot test One"; } public static void main(String[] args){ SpringApplication.run(AppLicationController.class ,args); } } 运行 在AppLicationController类处右键-执行run即可。 WindCoder * Date: 2017-11-12 * Time: 22:30 下午 */ @Controller @SpringBootApplication public class AppLicationController
class User < ApplicationRecord has_secure_password end 6.在applicatio_controller.rb中添加如下字段: class ApplicationController this file, see http://guides.rubyonrails.org/routing.html end 13,tokens控制器 class TokensController < ApplicationController
create 方法 [root@h202 blog]# cat app/controllers/articles_controller.rb class ArticlesController < ApplicationController articles_controller.rb [root@h202 blog]# cat app/controllers/articles_controller.rb class ArticlesController < ApplicationController articles_controller.rb [root@h202 blog]# cat app/controllers/articles_controller.rb class ArticlesController < ApplicationController
articles_controller.rb [root@h202 blog]# cat app/controllers/articles_controller.rb class ArticlesController < ApplicationController articles_controller.rb [root@h202 blog]# cat app/controllers/articles_controller.rb class ArticlesController < ApplicationController articles_controller.rb [root@h202 blog]# cat app/controllers/articles_controller.rb class ArticlesController < ApplicationController
request, response); requestContextMap.put("dispatcher", dispatcher); // Create ApplicationController instance ApplicationController applicationController = new ApplicationControllerImpl (); // Request processing ResponseContext responseContext = applicationController.handleRequest (requestContextMap); // Response processing applicationController.handleResponse
articles_controller.rb [root@h202 blog]# cat app/controllers/articles_controller.rb class ArticlesController < ApplicationController end end [root@h202 blog]# head -n 4 app/controllers/articles_controller.rb class ArticlesController < ApplicationController
创建了一个叫 ArticlesController 的类,继承自 ApplicationController 这次报错变了,成了找不到 new 方法 ---- 定义 new 方法 [root@h202 articles_controller.rb [root@h202 blog]# cat app/controllers/articles_controller.rb class ArticlesController < ApplicationController
#without paginagtion class PostsController < ApplicationController def index @posts = Post.all.order ('created_at desc') end end #with pagination class PostsController < ApplicationController def
调用 render 方法 调用 redirect_to 方法 调用 head 方法,向浏览器发送只含HTTP首部的响应 一个控制器: class BooksController < ApplicationController 指定控制器的布局 在控制器中使用 layout 声明,可以覆盖默认使用的布局约定: class ProductsController < ApplicationController layout "inventory" end 若要指定整个应用使用的布局,可以在ApplicationController类中使用layout声明: class ApplicationController < ActionController ::Base layout "main" end 在运行时选择布局 使用符号把布局延后到处理请求时再选择: class ProductsController < ApplicationController 根据条件设定布局 使用 :only 和 :except 选项,可以设定条件 class ProductsController < ApplicationController layout "product
comments_controller.rb [root@h202 blog]# cat app/controllers/comments_controller.rb class CommentsController < ApplicationController end [root@h202 blog]# head -n 4 app/controllers/comments_controller.rb class CommentsController < ApplicationController
password" => :string},{"user" => :string}], :returns => [:string] end Controller class BlogController < ApplicationController
1 namespace CompanySourceSearch.ApplicationController.Interface 2 { 3 using CompanySourceSearch.Service.Contract 1 namespace CompanySourceSearch.ApplicationController 2 { 3 using CompanySourceSearch.ApplicationController.Interface CompanySourceSearch.ServiceDto.Response; 5 using CompanySourceSearch.ServiceDto.Request; 6 using CompanySourceSearch.ApplicationController.Interface 1 namespace CompanySourceSearch.ApplicationController 2 { 3 using CompanySourceSearch.ApplicationController.Interface 1 namespace CompanySourceSearch.ApplicationController 2 { 3 using CompanySourceSearch.ApplicationController.Interface
comments_controller.rb [root@h202 blog]# cat app/controllers/comments_controller.rb class CommentsController < ApplicationController
articles_controller.rb [root@h202 blog]# cat app/controllers/articles_controller.rb class ArticlesController < ApplicationController
streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/ApplicationController.java
articles_controller.rb [root@h202 blog]# cat app/controllers/articles_controller.rb class ArticlesController < ApplicationController
comments.scss [root@h202 blog]# cat app/controllers/comments_controller.rb class CommentsController < ApplicationController
comments_controller.rb [root@h202 blog]# cat app/controllers/comments_controller.rb class CommentsController < ApplicationController
articles_controller.rb [root@h202 blog]# cat app/controllers/articles_controller.rb class ArticlesController < ApplicationController