Skip to content

Instantly share code, notes, and snippets.

@asouza
Created September 1, 2010 19:55
Show Gist options
  • Save asouza/561238 to your computer and use it in GitHub Desktop.
Save asouza/561238 to your computer and use it in GitHub Desktop.
package br.com.caelum.vraptor.scala;
import java.io.File;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import br.com.caelum.vraptor.ioc.Component;
import br.com.caelum.vraptor.ioc.RequestScoped;
import br.com.caelum.vraptor.resource.ResourceMethod;
import br.com.caelum.vraptor.view.AcceptHeaderToFormat;
import br.com.caelum.vraptor.view.DefaultPathResolver;
@Component
@RequestScoped
public class ScalatePathResolver extends DefaultPathResolver {
private final ServletContext context;
public ScalatePathResolver(HttpServletRequest request,
ServletContext context,
AcceptHeaderToFormat acceptHeaderToFormat) {
super(request, acceptHeaderToFormat);
this.context = context;
}
protected String getPrefix() {
return "/WEB-INF/ssp/";
}
protected String getExtension() {
return "ssp";
}
@Override
public String pathFor(ResourceMethod method) {
String path = super.pathFor(method);
String realPathToViewFile = context.getRealPath(path);
return new File(realPathToViewFile).exists() ? path : path.replace(
"/WEB-INF/ssp", "/WEB-INF/jsp").replace(".ssp", ".jsp");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment