Simple Blog App - Grails Typing CST Test
Loading…
Simple Blog App — Grails Code
Demonstrates a simple Grails controller and GSP view for listing blog posts using GORM.
// grails-app/controllers/com/example/BlogController.groovy
package com.example
class BlogController {
def index() {
def posts = Post.list()
[posts: posts]
}
def show(Long id) {
def post = Post.get(id)
[post: post]
}
}
// grails-app/domain/com/example/Post.groovy
package com.example
class Post {
String title
String content
}
// grails-app/views/blog/index.gsp
<h1>Blog Posts</h1>
<ul>
<g:each in="${posts}" var="post">
<li><g:link action="show" id="${post.id}">${post.title}</g:link></li>
</g:each>
</ul>Grails Language Guide
Grails is a powerful web application framework for the Groovy programming language, designed to simplify development with convention-over-configuration, rapid prototyping, and integration with the Java ecosystem.
Primary Use Cases
- ▸Web applications with dynamic content
- ▸RESTful APIs and microservices
- ▸Enterprise software leveraging Java ecosystem
- ▸E-commerce and SaaS platforms
- ▸Rapid prototyping of full-stack applications
Notable Features
- ▸Convention-over-configuration for faster setup
- ▸Scaffolding for automatic CRUD interfaces
- ▸GORM for ORM and database management
- ▸Built-in testing support with Spock and JUnit
- ▸Integration with Spring Boot and Java libraries
Origin & Creator
Created by Graeme Rocher in 2005, Grails is maintained by Object Computing Inc. (OCI) and the Grails community.
Industrial Note
Grails is popular in enterprise-grade applications and startups needing rapid development while leveraging Java libraries and Spring Boot features.