Domanda

For an action method:

@Action("/hello/${name}")
public String world() {
   value = "Hello "+name+"!";
   return "#world";
}

how to render the JSP /hello/world.jsp under WEB-INF? Is there a config alternative to add a prefix to resultPath.

Thanks Aanand

È stato utile?

Soluzione

Currently there is no such prefix (nice idea, though! We will add it in the next release :).

Meanwhile, you can modify the result very easily by overriding the ResultMapper:

public class MyResultMapper extends ResultMapper {

@Override
public String resolveResultPath(ActionConfig cfg, String resultValue) {
        String resultPath = super.resolveResultPath(cfg, resultValue);
        resultPath = "/WEB-INF" + resultPath;
        return resultPath;
    }
}

Now all you have to do is to register your result mapper. You can do this in several ways; one way might be to follow these steps:

1) Add your custom Madvoc WebApplication by registering it in web.xml:

<filter>
    <filter-name>madvoc</filter-name>
    <filter-class>jodd.madvoc.MadvocServletFilter</filter-class>
    <init-param>
        <param-name>madvoc.webapp</param-name>
        <param-value>....MyWebApplication</param-value>
    </init-param>
...
</filter>

2) and then implement it:

public class MyWebApplication extends WebApplication {

    @Override
    public void registerMadvocComponents() {
        super.registerMadvocComponents();
        registerComponent(MyResultMapper.class);
    }

Done, you don't have to change any of your Madvoc actions, all JSPs are now searched under the WEB-INF (or whatever folder you put there).

EDIT: as promised, see latest commit, it adds new Madvoc configuration flag.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top