Coder Social home page Coder Social logo

radishmvc-demo's Introduction

RadishMVC

这是一款应用于javaee项目的的轻量级MVC框架,类似于struts。主要特点:

  • 使用起来简单到没朋友,而且经测试效率很高,非常适合小型网站使用

  • 基于注解实现,完全没有配置文件

下载

当前最新版本V0.0.2,下载地址:

https://github.com/wuguohu/radishmvc-demo/raw/master/src/main/webapp/WEB-INF/lib/radish-mvc-0.0.2-SNAPSHOT.jar

使用说明

  • web.xml添加filter
  <filter>
    <filter-name>radish-mvc</filter-name>
    <filter-class>win.dord.open.radishmvc.RadishFilter</filter-class>
    <init-param>
      <param-name>actionParam</param-name>
      <param-value>method</param-value>
    </init-param>
    <init-param>
      <param-name>view</param-name>
      <param-value>/</param-value>
    </init-param>
  </filter>
  <filter-mapping>
    <filter-name>radish-mvc</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  • 业务类(Service)实现ActionService
package com.radishmvc.demo.service;

import win.dord.open.radishmvc.service.ActionService;

public abstract class BaseService extends ActionService{

}
package com.radishmvc.demo.service;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import win.dord.open.radishmvc.annotation.Action;
import win.dord.open.radishmvc.annotation.Param;
import win.dord.open.radishmvc.annotation.Service;

@Service("/user")
public class UserService extends BaseService {
	Logger logger = LogManager.getLogger(UserService.class);
	@Param("username")
	private String user;
	@Param
	private String password;

	@Override
	public String execute() {
		return null;
	}
	
	@Action
	public String login() {
		logger.info("login");
		//do something
		getRequest().setAttribute("user", user);
		getRequest().setAttribute("password", password);
		return "result.jsp";
	}
	

}
  • 注解说明

@Service 注解标识业务类的访问路径,如@Service("/home")。此注解必须传入访问路径,否则不做解析

@Action 注解标识业务类的实际操作方法,可以传参标识别名。支持@Action或@Action("newname")

@Param 注解标识自动绑定入参。支持@Param或@Param("newname")

依赖

项目依赖于apache log4j 2.0及以上版本

radishmvc-demo's People

Contributors

wuguohu avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.