Jodd快速开发MVC - 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 中添加依赖
    <dependency>
        <groupId>org.jodd</groupId>
        <artifactId>jodd-madvoc</artifactId>
        <version>3.4.8</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.5</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>1.7.5</version>
    </dependency>

 

2. 添加madvoc的过滤器

文件: web.xml
    <filter>
        <filter-name>madvoc</filter-name>
        <filter-class>jodd.madvoc.MadvocServletFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>madvoc</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

 

3. 添加 Action

文件: webit/demo/madvoc/HelloAction.java
    // Copyright...
    package webit.demo.madvoc;

    import jodd.madvoc.meta.Action;
    import jodd.madvoc.meta.MadvocAction;

    /**
     *
     * @author zqq90
     */
    @MadvocAction
    public class HelloAction {

        @Action
        public Object view() {
            return "text:hello madvoc";
        }
    }

4. OK 完成,验收

启动 tomcat
    [http-apr-8080-exec-36] INFO jodd.madvoc.Madvoc - Madvoc starting...
    [http-apr-8080-exec-36] INFO jodd.madvoc.Madvoc - Default Madvoc web application created.
    [http-apr-8080-exec-36] INFO jodd.madvoc.Madvoc - Configuring Madvoc using default automagic configurator
    [http-apr-8080-exec-36] INFO jodd.madvoc.config.AutomagicMadvocConfigurator - Madvoc configured in 50 ms. Total actions: 1
    [http-apr-8080-exec-36] INFO jodd.madvoc.Madvoc - Madvoc is up and running.
浏览器打开 http://localhost:8080/ [部署的项目名字] /hello.html
hello madvoc

 示例源文件

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值