oblac / jodd

Jodd! Lightweight. Java. Zero dependencies. Use what you like.
https://jodd.org
BSD 2-Clause "Simplified" License
4.06k stars 724 forks source link

default view page should be configable #594

Closed yujinping closed 6 years ago

yujinping commented 6 years ago

When I using jodd 4.3 the following action code is:

@MadvocAction
public class IndexAction extends BaseAction {
    @Action("/")
    public void execute(){
    }
}

And when I visit http://localhost/ ,the response is 404. jodd log:

8455 [DEBUG] j.m.r.AbstractTemplateViewActionResult.render:79 - new target: /:
8455 [DEBUG] j.m.r.ServletDispatcherActionResult.targetExists:99 - target check: /.jspf
8456 [DEBUG] j.m.r.ServletDispatcherActionResult.targetExists:99 - target check: /.jsp

Current behavior

No default page and 404

Expected behavior

Using global config to set the default page for @Action("/") or @Action("/a/b/c/") action path end with "/" for example: @Action("/") => /index.jsp @Action("/a/b/c/")=>/a/b/c/index.jsp maybe in joy.props: servletDispatcherActionResult.defaultViewPageName=index index.jsp is a global configuration and can be override. After config the props value, then the target check of the ServletDispatcherActionResult should be

8455 [DEBUG] j.m.r.AbstractTemplateViewActionResult.render:79 - new target: /:
8455 [DEBUG] j.m.r.ServletDispatcherActionResult.targetExists:99 - target check: /index.jspf
8456 [DEBUG] j.m.r.ServletDispatcherActionResult.targetExists:99 - target check: /index.jsp
8455 [DEBUG] j.m.r.ServletDispatcherActionResult.targetExists:99 - target check: /.jspf
8456 [DEBUG] j.m.r.ServletDispatcherActionResult.targetExists:99 - target check: /.jsp
igr commented 6 years ago

DOne. But I will move config to MadvocConfig - trying to centralize all configurations as it is more developer friendly.

yujinping commented 6 years ago

@igr thanks for your working! move to MadvocConfig is very nice. thx.