text生成自定义导轨模板(代码片段)

text生成自定义导轨模板(代码片段)

run 'rm README.doc'
run 'touch README.md'

gem 'haml-rails'

gem_group :development, :test do
  gem 'rspec-rails' 
  gem 'annotate'
  gem 'guard-rspec'
end

run 'bundle install'
generate 'rspec:install'
git :init 
git add: '--all', commit: '-m "Initial Commit" '
```rails new <project name> -T -m <path to template file>```  (-T Stops default testing files from being created )

相关内容

myeclipse自定义servlet模板

  • 每次用MyEclipse默认的servlet的模板创建servlet的时候,里面会生成好多没有用的代码。因此,我们可以自定义servlet模板。步骤如下:
  1. 找到com.genuitec.eclipse.wizards_11.5.0.me201310291746.jar 文件,该文件在MyEclipse(本人安装的是MyEclipse Professional 2014)安装目录下的/plugins

     

     

  2. 打开com.genuitec.eclipse.wizards_11.5.0.me201310291746.jar,找到templates

     

  3. 进入templates里面有Servlet.java文件,打开,修改里面的代码,就可以自己定义自己想要的servlet模板。

     

  • 打开Servlet.java文件,修改里面的代码为:   
 1 <aw:import>java.io.IOException</aw:import>
 2 <aw:import>java.io.PrintWriter</aw:import>
 3 
 4 <aw:import>javax.servlet.ServletException</aw:import>
 5 <aw:import>javax.servlet.http.HttpServlet</aw:import>
 6 <aw:import>javax.servlet.http.HttpServletRequest</aw:import>
 7 <aw:import>javax.servlet.http.HttpServletResponse</aw:import>
 8 
 9 <aw:parentClass>javax.servlet.http.HttpServlet</aw:parentClass>
10 
11 <aw:method name="doGet">
12     public void doGet(HttpServletRequest request, HttpServletResponse response)
13         throws ServletException, IOException {
14 
15     }
16 
17 </aw:method>
18 
19 <aw:method name="doPost">
20     
21     public void doPost(HttpServletRequest request, HttpServletResponse response)
22         throws ServletException, IOException {
23         doGet(request,response);
24         
25     }
26 
27 </aw:method>
View Code
  • 然后创建出来的servlet为如下样式:
 1 package com.bookStore.web.servlet;
 2 
 3 import java.io.IOException;
 4 
 5 import javax.servlet.ServletException;
 6 import javax.servlet.http.HttpServlet;
 7 import javax.servlet.http.HttpServletRequest;
 8 import javax.servlet.http.HttpServletResponse;
 9 
10 public class LoginServlet extends HttpServlet {
11 
12     public void doGet(HttpServletRequest request, HttpServletResponse response)
13             throws ServletException, IOException {
14 
15     }
16 
17     public void doPost(HttpServletRequest request, HttpServletResponse response)
18             throws ServletException, IOException {
19         doGet(request, response);
20 
21     }
22 
23 }
View Code

 

赞(1)

文章来源于网络,原文链接请点击 这里
文章版权归作者所有,如作者不同意请直接联系小编删除。
作者:author