前一段时间做项目的时候用的这个框架,很小也很健全的一个框架,主要用到的功能都有,对其他框架和中间件的支持也很到位,记录一下
<dependency>
<groupId>org.nutz</groupId>
<artifactId>nutz</artifactId>
<version>1.r.62</version>
</dependency>
就这一个jar包就能满足基本的开发了
<dependency>
<groupId>org.nutz</groupId>
<artifactId>nutz</artifactId>
<version>1.r.62</version>
</dependency>
<!-- mysql驱动 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.40</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<!-- Druid连接池 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.0.27</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.8</version>
</dependency>
<filter>
<filter-name>nutz</filter-name>
<filter-class>org.nutz.mvc.NutFilter</filter-class>
<init-param>
<param-name>modules</param-name>
<param-value>com.test.controller.MainController</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>nutz</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
启动类
package com.test.controller;
public class MainController {
public static void main(String[] args) {
System.out.println("========================mainController
========================");
}
}
package com.test.controller;
import java.io.UnsupportedEncodingException;
import javax.servlet.http.HttpServletRequest;
import org.nutz.mvc.adaptor.PairAdaptor;
import org.nutz.mvc.annotation.AdaptBy;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Modules;
import org.nutz.mvc.annotation.Ok;
import com.test.dao.UserDao;
@Modules(scanPackage = true)
@At("/test")
@Ok("json")
public class NutzController {
@AdaptBy(type = PairAdaptor.class)
@At("/hello")
@Ok("json")
public String hello() throws UnsupportedEncodingException {
System.out.println("Hello World");
return "Hello World";
}
}