科技行者

行者学院 转型私董会 科技行者专题报道 网红大战科技行者

知识库

知识库 安全导航

至顶网软件频道Groovy轻松入门——Grails实战基础篇

Groovy轻松入门——Grails实战基础篇

  • 扫一扫
    分享文章到微信

  • 扫一扫
    关注官方公众号
    至顶头条

在学习任何东西之前,最重要的是培养兴趣,Groovy世界最耀眼的技术之一

作者:山风小子 来源:蛟龍居 2007年11月18日

关键字:

  • 评论
  • 分享微博
  • 分享邮件

在本页阅读全文(共4页)

 

ok.gsp:

9,修改demo\grails-app\conf\ApplicationBootStrap.groovy,将一个User实例保存到数据库(grails自带hsqldb和jetty)中,内容如下:

class ApplicationBootStrap {

     def init = { servletContext ->
         new User(name: "demo", password: "123456").save()
     }
     def destroy = {
     }
} 

 

10,在“命令行”中,输入“grails run-app”,运行我们的Web应用,输出如下:

D:\Temp\grails_apps\demo>grails run-app

Welcome to Grails 0.4.2 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: D:\D\MY_DEV\grails

Base Directory: D:\Temp\grails_apps\demo
Environment set to development
Running script D:\D\MY_DEV\grails\scripts\RunApp.groovy
Compiling sources
   [delete] Deleting directory D:\Temp\grails_apps\demo\web-app\WEB-INF\grails-a
pp
    [mkdir] Created dir: D:\Temp\grails_apps\demo\web-app\WEB-INF\grails-app\vie
ws
    [mkdir] Created dir: D:\Temp\grails_apps\demo\web-app\WEB-INF\grails-app\i18
n
     [copy] Copying 8 files to D:\Temp\grails_apps\demo\web-app\WEB-INF\grails-a
pp\views
[native2ascii] Converting 1 file from D:\Temp\grails_apps\demo\grails-app\i18n t
o D:\Temp\grails_apps\demo\web-app\WEB-INF\grails-app\i18n
Attempting to load [13] core plugins
Grails plug-in [i18n] with version [0.4.2] loaded successfully
Grails plug-in [quartz] with version [0.4.2] loaded successfully
Grails plug-in [core] with version [0.4.2] loaded successfully
Grails plug-in [domainClass] with version [0.4.2] loaded successfully
Grails plug-in [controllers] with version [0.4.2] loaded successfully
Attempting to load [0] user defined plugins
Grails plug-in [dataSource] with version [0.4.2] loaded successfully
Grails plug-in [codecs] with version [0.4.2] loaded successfully
Grails plug-in [hibernate] with version [0.4.2] loaded successfully
Grails plug-in [services] with version [0.4.2] loaded successfully
Grails plug-in [scaffolding] with version [0.4.2] loaded successfully
[RuntimeConfiguration] Configuring for environment: Development
Building new Hibernate SessionFactory
Neither 'urlMap' nor 'mappings' set on SimpleUrlHandlerMapping
64 beans defined in application context [org.codehaus.groovy.grails.commons.spri
ng.GrailsWebApplicationContext;hashCode=6971605]
Using MessageSource [org.springframework.context.support.ReloadableResourceBundl
eMessageSource: basenames=[WEB-INF/grails-app/i18n/messages]]
Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticas
ter': using default [org.springframework.context.event.SimpleApplicationEventMul
ticaster@181d405]
     [copy] Copying 8 files to D:\Temp\grails_apps\demo\web-app\WEB-INF\grails-a
pp\views
[GrailsContextLoader] Grails application loaded.
Initializing filter 'grailsWebRequest'
Filter 'grailsWebRequest' configured successfully
Initializing filter 'reloadFilter'
Filter 'reloadFilter' configured successfully
Initializing servlet 'grails'
FrameworkServlet 'grails': initialization started
Using context class [org.codehaus.groovy.grails.commons.spring.GrailsWebApplicat
ionContext] for servlet 'grails'
Using MultipartResolver [org.springframework.web.multipart.commons.CommonsMultip
artResolver@1945696]
Using LocaleResolver [org.springframework.web.servlet.i18n.CookieLocaleResolver@
1c0bec5]
Unable to locate ThemeResolver with name 'themeResolver': using default [org.spr
ingframework.web.servlet.theme.FixedThemeResolver@1984161]
No HandlerAdapters found in servlet 'grails': using default
Unable to locate RequestToViewNameTranslator with name 'viewNameTranslator': usi
ng default [org.springframework.web.servlet.view.DefaultRequestToViewNameTransla
tor@688d6f]
FrameworkServlet 'grails': initialization completed in 187 ms
Servlet 'grails' configured successfully

11,打开浏览器,输入:http://localhost:8080/demo/login/login ,在Name处输入demo,Password处输入123456,点击‘Login’,跳转到成功页面:

Welcome demo
demo : 123456

查看本文来源

    • 评论
    • 分享微博
    • 分享邮件
    邮件订阅

    如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。

    重磅专题
    往期文章
    最新文章