Spring Batch有两种不同的下载方式(Spring Batch for two different downloads)
我需要为两种不同的下载类型实现Spring Batch。 根据用户类型,我想为他们提供两种不同的下载结果。 我从同一个地方读取它,以相同的方式处理它,但文件内容将是不同的。
我决定为它做两个不同的工作。
问题:是否可以重复使用Reader和Processor Bean来完成这两项工作?
I need to implement Spring Batch for two different download types. Based on the user type I would like to serve them two various download results. I read it from the same place, process it in the same way, but file content will be different.
I decided to go with two different jobs for it.
Questions: Is it possible to reuse Reader and Processor Beans for these two jobs?
原文:https://stackoverflow.com/questions/34726343
最满意答案
入门的基本代码:
# config/routes.rb Rails.application.routes.draw do resources :posts resources :authors constraints(PostUrlConstrainer.new) do get "/:id", to: "posts#show" end end # app/constraints/post_url_constrainer.rb class PostUrlConstrainer def matches?(request) title = request.path_parameters[:id] Post.find_by(title: title) end end # app/controllers/posts_controller.rb def set_post @post = Post.find_by(title: params[:id]) end
相关文章: Rails应用程序中每条路线的漂亮,简短的网址 - Arkency Blog
搜索
rails url constraint
似乎有所帮助。Basic code to get you started:
# config/routes.rb Rails.application.routes.draw do resources :posts resources :authors constraints(PostUrlConstrainer.new) do get "/:id", to: "posts#show" end end # app/constraints/post_url_constrainer.rb class PostUrlConstrainer def matches?(request) title = request.path_parameters[:id] Post.find_by(title: title) end end # app/controllers/posts_controller.rb def set_post @post = Post.find_by(title: params[:id]) end
Related article: Pretty, short urls for every route in your Rails app - Arkency Blog
Searching for
rails url constraint
seems to help.
相关问答
更多-
您可以使用此gem来为您的js app实现所有rails路由助手。 https://github.com/railsware/js-routes You can use this gem to implement all the rails route helpers for you js app. https://github.com/railsware/js-routes
-
使用resources ,它会自动为您创建命名路径。 我不会通过你的整个路由文件,但一个例子: get 'activation' => 'activations#new', :as => 'activation' get 'activate/:token' => 'activations#activate', :as => 'activate' post 'activations/edit' resources :activations, :only => [ :new, : ...
-
Rails Routes.rb(Rails Routes.rb)[2023-11-28]
Rails基于'约定优于配置'范例。 因此,“resources:users”行表示相应的UsersController支持所有标准CRUD方法< - 'Users'前缀与Controller,Model等匹配。 Rails is based around the 'convention over configuration' paradigm. As such, the "resources :users" line indicates that all the standard CRUD methods ... -
/:customer_code/jobs /:customer_code/jobs/new 您的链接看起来像/ 1234 / jobs / new,然后您可以访问控制器中的客户代码: params["customer_code"] 编辑: 如果要使用资源,请尝试此操作: scope '/:customer_code' do resources :jobs end /:customer_code/jobs /:customer_code/jobs/new Your link will look ...
-
Ruby on Rails routes.rb(Ruby on Rails routes.rb)[2022-10-08]
get ':controller(/:action(/:id(.:format)))' 在config/routes.rb文件中写入具有最低优先级(最后一行)的此行。 get ':controller(/:action(/:id(.:format)))' write this line with the lowest priority (last line) in the config/routes.rb file. -
你不能使用routes.rb来做到这一点,但它足够简单,可以设置路由,获取内容类型和重定向。 就像是: routes.rb match.resources :photos match.resources :mobile_photos match.resources :blog #everything_else all resource and named routes before match ':article_id' => 'articles#redirect', :via => :get, :as ...
-
如何为虚荣URL设置Rails routes.rb,无需前缀(How to setup Rails routes.rb for Vanity URL w/o requiring a prefix)[2022-03-22]
入门的基本代码: # config/routes.rb Rails.application.routes.draw do resources :posts resources :authors constraints(PostUrlConstrainer.new) do get "/:id", to: "posts#show" end end # app/constraints/post_url_constrainer.rb class PostUrlConstrainer ... -
如何删除routes.rb中为路径中的参数生成的前缀(How to remove the prefix generated in routes.rb for the params in the path)[2024-01-09]
你可以这样做: resources :users do member do get 'account_setting' end end 要添加成员路由,请将成员块添加到资源块中。 有关文档,您可以查看http://api.rubyonrails.org/classes/ActionDispatch/Routing/Mapper/Resources.html You can do it as follows: resources :users do ... -
Ruby on Rails routes.rb(Ruby on Rails routes.rb)[2023-11-06]
尝试将以下内容放在routes.rb的末尾 match ':action' => 'static#:action' 然后,对/help的请求将呈现app/views/static/help.html.erb 。 不要忘记创建static控制器,即使它是空的。 Try putting the following at the end of routes.rb match ':action' => 'static#:action' A request to /help will then render ap ... -
这将是您正在寻找的确切行https://github.com/rails/rails/blob/master/railties/lib/rails/application/routes_reloader.rb#L40 如果您希望您的应用知道其他路由文件,请在config/application.rb添加以下行 config.paths['config/routes'] << 'config/routes1.rb' 说明:你看,Rails应用程序基本上是一个引擎。 更多关于这一点 。 每个引擎都可以有自定义 ...