Fix URL dispatching.

This commit is contained in:
Christian P. MOMON 2013-06-30 02:56:12 +02:00
parent 7bb2bfad20
commit 653d2bedca

View file

@ -32,14 +32,14 @@ public class SimpleServletDispatcher extends HttpServlet
private static final long serialVersionUID = -3471226305721330069L; private static final long serialVersionUID = -3471226305721330069L;
static private Logger logger = LoggerFactory.getLogger(ServletDispatcher.class); static private Logger logger = LoggerFactory.getLogger(ServletDispatcher.class);
static final protected Pattern SHORT_REWRITED_URL_CLASS = Pattern.compile("^([^-]+)-.+\\.xhtml$"); static final private Pattern SHORT_REWRITED_URL_CLASS = Pattern.compile("^([^-]+)-.+\\.xhtml$");
static final protected Pattern SHORT_REWRITED_URL_PARAMETERS = Pattern.compile("^[^-]+-(.+)\\.xhtml$"); static final private Pattern SHORT_REWRITED_URL_PARAMETERS = Pattern.compile("^[^-]+-(.+)\\.xhtml$");
static final protected Pattern LONG_REWRITED_URL_CLASS = Pattern.compile("^([^-]+)-/.*$"); static final private Pattern LONG_REWRITED_URL_CLASS = Pattern.compile("^([^-]+)-/.*$");
// static final protected Pattern LONG_REWRITED_URL_PARAMETERS = // static final protected Pattern LONG_REWRITED_URL_PARAMETERS =
// Pattern.compile("^.+-/(.)+*$"); // Pattern.compile("^.+-/(.)+*$");
static final protected Pattern REWRITE_PARAMETER = Pattern.compile("[^%\\w\\d]"); static final private Pattern REWRITE_PARAMETER = Pattern.compile("[^%\\w\\d]");
protected String webclassesRootPath; private String webclassesRootPath;
/** /**
* "Code can be shortest, speedest and memory smallest, but not the three in same time, only two" * "Code can be shortest, speedest and memory smallest, but not the three in same time, only two"
@ -96,13 +96,21 @@ public class SimpleServletDispatcher extends HttpServlet
// //
/* /*
* In past, possibility to use the servlet path was enable. It is too * In past, possibility to use the servlet path was enable. It is too
* complexe, not kiss mind. String path; if (request.getPathInfo() == * complexe, not kiss mind.
* null) { // web.xml url-pattern= *.xhtml path = *
* request.getServletPath(); } else { // web.xml url-pattern = /* path = * String path;
* request.getPathInfo(); } * if (request.getPathInfo() == null)
* {
* // web.xml url-pattern= *.xhtml
* path = request.getServletPath();
* }
* else
* {
* // web.xml url-pattern =
* path = request.getPathInfo();
* }
*/ */
// String path = request.getRequestURI(); String path = request.getRequestURI();
String path = request.getPathInfo();
if ((!path.endsWith("/")) && (!path.endsWith(".xhtml")) && (!path.contains("-/"))) if ((!path.endsWith("/")) && (!path.endsWith(".xhtml")) && (!path.contains("-/")))
{ {