Jodd快速开发MVC - hello madvoc

转自:http://my.oschina.net/zqq90/blog/185144

 

摘要  使用Jodd-madvoc快速搭建MVC

 

Jodd Madvoc - hello madvoc

Jodd MVC 最简单实践

1. 准备Jar

  • jodd-3.4.8.jar
  • slf4j-api-1.7.5.jar
  • slf4j-simple-1.7.5.jar

如果使用 maven 只需在 pom.xml 中添加依赖

01 <dependency>
02     <groupId>org.jodd</groupId>
03     <artifactId>jodd-madvoc</artifactId>
04     <version>3.4.8</version>
05 </dependency>
06 <dependency>
07     <groupId>org.slf4j</groupId>
08     <artifactId>slf4j-api</artifactId>
09     <version>1.7.5</version>
10 </dependency>
11 <dependency>
12     <groupId>org.slf4j</groupId>
13     <artifactId>slf4j-simple</artifactId>
14     <version>1.7.5</version>
15 </dependency>

2. 添加madvoc的过滤器

文件: web.xml

1 <filter>
2     <filter-name>madvoc</filter-name>
3     <filter-class>jodd.madvoc.MadvocServletFilter</filter-class>
4 </filter>
5 <filter-mapping>
6     <filter-name>madvoc</filter-name>
7     <url-pattern>/*</url-pattern>
8 </filter-mapping>

3. 添加 Action

文件: webit/demo/madvoc/HelloAction.java

01// Copyright...
02 package webit.demo.madvoc;
03 
04 import jodd.madvoc.meta.Action;
05 import jodd.madvoc.meta.MadvocAction;
06 
07/**
08  *
09  * @author zqq90
10  */
11@MadvocAction
12 public class HelloAction {
13 
14     @Action
15     public Object view() {
16         return "text:hello madvoc";
17     }
18}

4. OK 完成,验收

启动 tomcat

1 [http-apr-8080-exec-36] INFO jodd.madvoc.Madvoc - Madvoc starting...
2 [http-apr-8080-exec-36] INFO jodd.madvoc.Madvoc - Default Madvoc web application created.
3 [http-apr-8080-exec-36] INFO jodd.madvoc.Madvoc - Configuring Madvoc using defaultautomagic configurator
4 [http-apr-8080-exec-36] INFO jodd.madvoc.config.AutomagicMadvocConfigurator - Madvoc configured in 50 ms. Total actions: 1
5 [http-apr-8080-exec-36] INFO jodd.madvoc.Madvoc - Madvoc is up and running.

浏览器打开 http://localhost:8080/ [部署的项目名字] /hello.html

1hello madvoc
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值