Closed zhang20084 closed 1 year ago
Parameters should not have any effect on page decorating. Are you trying to create a rule based on parameters or the file part of the url?
But I can't, for example < mapping path="/ * pjax * " exclude="true" > It can't please write a example, how to make the parameter using another decorator. Thank you very much.
lose hope
change web.xml file: filter part to my filter 'com.alexgaoyh.MutiModule.Dubbo.RWSeperate.consumer.web.util.sitemesh.filter.ParamConfigurableSiteMeshFilter'
`public class ParamConfigurableSiteMeshFilter extends ConfigurableSiteMeshFilter {
protected void applyCustomConfiguration(SiteMeshFilterBuilder builder) {
DecoratorSelector<WebAppContext> defaultDecoratorSelector = builder.getDecoratorSelector();
builder.setCustomDecoratorSelector(new ParamDecoratorSelector(defaultDecoratorSelector));
}
}`
`public class ParamDecoratorSelector implements DecoratorSelector
private DecoratorSelector<WebAppContext> defaultDecoratorSelector;
public ParamDecoratorSelector(DecoratorSelector<WebAppContext> defaultDecoratorSelector) {
this.defaultDecoratorSelector = defaultDecoratorSelector;
}
@Override
public String[] selectDecoratorPaths(Content content, WebAppContext context) throws IOException {
HttpServletRequest request = context.getRequest();
String decorator = request.getParameter("decorator");
if (StringUtilss.isNotBlank(decorator) && decorator.equals("true")) {
return new String[] {};
}
// Otherwise, fallback to the standard configuration
return defaultDecoratorSelector.selectDecoratorPaths(content, context);
}
}`
The reason in this particular case is you are using the wrong mime type. You should not be using text/html for ajax.
However, if this is still something you are interested in us addressing, we are happy to look into it.
This demonstrates that SiteMesh does not decorate json by default:
https://github.com/sitemesh/sitemesh3/commit/f68b087fd36928abe48bfc7595d946986c9e0917
If you want to decorate by parameters. The simplest way is to add a meta tag inside the page you wish to decorate that is dynamic based on the parameter being present.
Here is an example:
<c:if test="${not empty param.bootstrap}">
<meta name="decorator" content="bootstrap.jsp${not empty param.doubled?',chaining.html':''}" />
</c:if>
If you can define a more specific need that can not be achieved with the current implementation, we are more than happy to offer a solution.
Do not use decorator What do I do