Skip to content

daileyet/openlibs.easywebframework

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Easyweb: MVC framework 🐫💥

Easyweb is a java web MVC framework.It is free under Apache 2 license. Easyweb is simple, pure and easy to understand. You can use this framework to do:

  • Bind web request to a java method in controller class
  • Use POJO as web Controller
  • Support multi-type response of java method as web View
  • Support annotation configuration
  • Add security controller flexibly and quickly
  • Enable/disable simple web monitor to view Controllers and Filters

Getting start

Add dependency to pom.xml

<dependency>
  <groupId>com.openthinks</groupId>
  <artifactId>openlibs.easyweb</artifactId>
  <version>1.2.1</version>
</dependency>

Configure project by annotationed POJO class

/*
 * File name:com.openthinks.easywebexample.EasyWebConfigure
*/
@EasyConfigure
@ScanPackages({ "com.openthinks.easywebexample" })
@RequestSuffixs(".do,.htm")
public class EasyWebConfigure{}

Enable easyweb in web.xml

  ...
  <servlet>
    <servlet-name>easyweb</servlet-name>
    <servlet-class>com.openthinks.easyweb.EasyWebDispatcher</servlet-class>
    <load-on-startup>0</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>easyweb</servlet-name>
    <url-pattern>*.do</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>easyweb</servlet-name>
    <url-pattern>*.htm</url-pattern>
  </servlet-mapping>
  <listener>
    <listener-class>com.openthinks.easyweb.context.WebContextLoadListener</listener-class>
  </listener>
  <context-param>
    <param-name>configureClassName</param-name>
    <param-value>com.openthinks.easywebexample.EasyWebConfigure</param-value>
  </context-param>
  ...

Create Controller with POJO class

@Controller
public class HelloController {
	@Mapping("/index")
	public String index() {
		return "hello.jsp";
	}
}    

Deploy app to web container and run

After deploy your web application to Servlet container(Tomcat/Resin)

Access by URL: http://localhost:8080/easywebexample/index.htm or http://localhost:8080/easywebexample/index.do to get page which render by hello.jsp

easywebexample is app web root context.

Sample

easywebexample

Documentation

You can continue with quick start or refer to the documentation.