Giter Site home page Giter Site logo

Comments (17)

juqkai avatar juqkai commented on May 3, 2024

我记得在MVC 改版之前,AtMap主要作用确实是保存路径映射, 但是改版后已经替换成 UrlMapping 接口来做路径映射了吧.

而现在AtMap最在的作用却是给 mapPath 提供功能(就是我之前添加的一个东西, 结果我差点忘了)...
所以,注定上面这么调用会出问题...

from nutz.

zozoh avatar zozoh commented on May 3, 2024

还是应该加上吧, 反正就是存一个 Map 到 ServletContext 里而已
加个 Junit 来确保这个 Bug 好了

from nutz.

juqkai avatar juqkai commented on May 3, 2024

我做了简单的调整。在mvcSetup分支中

  1. 去掉pathMap
  2. 去掉@at中的key配置
  3. 去掉AtMap类,并使用UrlMapping替代在servletContent中的内容。

因为这样的调整导致接口有变化,所以没有合并,看看有没有必要这么处理。

[删除]
另外,我们可不可以在ActionInvoker中添加一个操作过滤器呢?
如:
public interface ActionInvokerFilter{
boolean filter(String path);
}
这样,直接根据每个filter的结果决定当前Invoker是否执行。
[/删除]

想了一下,这个东西可以直接用filter来做。那直接在ActionInvoker里面添加一个是否执行的属性,然后在setup的时候可以修改应该也能提前控制ActionInvoker是否执行吧

from nutz.

zozoh avatar zozoh commented on May 3, 2024

强烈反对

首先, UrlMapping 封装了映射行为
其次,在 ActionInvoker 前面再加 Filter 让本来已经略显复杂的 Mvc 映射逻辑更加臃肿
最后,AtMap 不过是一个用 kep 来描述 url 的信息集合,在 @at 中声明 key , 应该是最简单直观的方法了

from nutz.

zozoh avatar zozoh commented on May 3, 2024

增加测试用例:

org.nutz.mvc.init.AtMapInitTest
> test_at_map

from nutz.

conanca avatar conanca commented on May 3, 2024

换用1.b.39问题依旧:

    AtMap atMap = config.getAtMap();
    //AtMap atMap = Mvcs.getAtMap(config.getServletContext()); // 这句也一样
    logger.debug("AtMap size:" + atMap.size());

日志输出:
2011-08-15 10:19:52,015 [main] DEBUG xxx.MvcSetup - AtMap size:0

from nutz.

zozoh avatar zozoh commented on May 3, 2024

呃,如果不写 @at(key="abc", value="/myapp/abc") 那么 AtMap 的 url ,key值是啥?
现在,只有 声明了 @at(key=xxx) 的,才会加到 AtMap 里

from nutz.

zozoh avatar zozoh commented on May 3, 2024

或者 AtMap 增加一个方法,叫 List getUrls() ?

from nutz.

conanca avatar conanca commented on May 3, 2024

嘿嘿,如果能加个 List getMethods()更好

from nutz.

zozoh avatar zozoh commented on May 3, 2024

你实际上更需要

Method getMethod(String url) 

吧?

from nutz.

wendal avatar wendal commented on May 3, 2024

@zozoh, 应该他是想获取全部标注了@at的方法

from nutz.

conanca avatar conanca commented on May 3, 2024

兽说的没错,我想在应用启动时,获取所有的入口方法。

from nutz.

wendal avatar wendal commented on May 3, 2024

这样的话,我倒是有个简单的方法,继承UrlMappingImpl
这个类的map属性,包含全部方法

from nutz.

zozoh avatar zozoh commented on May 3, 2024

不想继承的原因是,因为不想暴露出 add 方法
这个好弄,我改改就成,反正能支持

 List getMethods() 

Method getMethod(getString url)

就是了

from nutz.

wendal avatar wendal commented on May 3, 2024

这样看来,暴露UrlMapping的内部属性给你,更好

from nutz.

zozoh avatar zozoh commented on May 3, 2024

? 为啥?

from nutz.

zozoh avatar zozoh commented on May 3, 2024

你现在可以

  Map<String, Method> map = Mvcs.getAtMap(servletContext).getMethodMapping();

from nutz.

Related Issues (20)

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.