Use the Rice Krad Web framework to quickly build an enterprise -level Java application
Use the Rice Krad Web framework to quickly build an enterprise -level Java application
Overview:
Rice Krad (Kuali Rapid Application Development) Web framework is an open source web application development framework based on Java and Spring MVC.It provides a rich set of tools and functions that can greatly simplify the development process of enterprise -level Java applications.This article will introduce you to how to use the Rice Krad Web framework to quickly build an enterprise Java application and provide some Java code example for reference.
step:
1. Environmental preparation
First, make sure that the following software has been installed in your development environment:
- Java Development Kit(JDK)
-JAVA integrated development environment (IDE) such as Eclipse or Intellij
-Apache Maven Construction Tool
2. Create Maven project
Create a new Maven project in IDE and add Rice Krad's dependency item to the pom.xml file of the project.You can find Rice Krad's dependency item coordinates in Maven central warehouse.
<dependency>
<groupId>org.kuali.rice.krad</groupId>
<artifactId>krad-web-framework</artifactId>
<version>3.0.0</version>
</dependency>
3. Create user interface (UI)
Rice Krad provides a set of powerful component libraries to quickly build a user interface.You can use KRAD -specific tagings (KSL) or JSP pages to define the layout and components of the user interface.
jsp
<%@ taglib uri="http://uif.kuali.org/tags/ui" prefix="kualiUI"%>
<kualiUI:form>
<kualiUI:inputField property="name" label="名称" required="true" />
<kualiui: inputField Property = "Email" label = "Email" Required = "TRUE" />
<kuliui:button ID="Submitbtn" text="提交" />
</kualiUI:form>
4. Create a controller (Controller)
In RICE KRAD, the controller class is responsible for processing requests and calling appropriate service classes to perform business logic.You can use the Spring MVC annotation to define the controller class and map the URL.
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@Controller
public class UserController {
@GetMapping("/user")
public String showUserForm() {
return "userForm";
}
@PostMapping("/user")
public String submitUserForm(User user) {
// Call other service class execution logic
return "successPage";
}
}
5. Configure route (routing)
In order to correct the request routing to the controller processing program, the routing rules of the application need to be configured.You can use the Spring MVC configuration file (such as XML or Javaconfig) to define the routing rules.
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.ViewResolverRegistry;
@Configuration
@EnableWebMvc
public class WebMvcConfig implements WebMvcConfigurer {
@Override
public void configureViewResolvers(ViewResolverRegistry registry) {
registry.jsp("/WEB-INF/views/", ".jsp");
}
}
6. Run application
Use Maven to build tool construction and packaging applications, and deploy the generated war files into the web server.You can view and test the user interface created by accessing the URL of the application.
in conclusion:
Using the Rice Krad Web framework can quickly build an enterprise -level Java application, it provides rich tools and functions and simplifies the development process.This article introduces the basic steps of using Rice KRAD and provides code example for reference.Now you can try to use this framework to develop your own Java application.