All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.geomajas.gwt.server.mvc.GwtResourceController Maven / Gradle / Ivy

There is a newer version: 2.4.3
Show newest version
/*
 * This is part of Geomajas, a GIS framework, http://www.geomajas.org/.
 *
 * Copyright 2008-2014 Geosparc nv, http://www.geosparc.com/, Belgium.
 *
 * The program is available in open source according to the GNU Affero
 * General Public License. All contributions in this program are covered
 * by the Geomajas Contributors License Agreement. For full licensing
 * details, see LICENSE.txt in the project root.
 */
package org.geomajas.gwt.server.mvc;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.geomajas.servlet.ResourceController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * A resource controller that searches both classpath and web context. This is a fallback controller for resources that
 * that are located in the GWT module. It allows direct fetching of those resources or getting them from the classpath.
 * This allows the configuration of GWT accessible images by their classpath location: 
 * 

* * String href = GWT.getModuleBaseURL() + "<configured classpath location>";

* Image.setUrl(href); * * * @author Jan De Moerloose */ public class GwtResourceController extends ResourceController { public GwtResourceController() { setCompressionAllowed(false); } @RequestMapping(value = "/**/*", method = RequestMethod.GET) public void getResource(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { super.getResource(request, response); } protected URL[] getRequestResourceUrls(String rawResourcePath, HttpServletRequest request) throws MalformedURLException { URL[] resources = super.getRequestResourceUrls(rawResourcePath, request); // try web context (prepending servlet path) if (resources == null || resources.length == 0) { rawResourcePath = request.getServletPath() + request.getPathInfo(); resources = super.getRequestResourceUrls(rawResourcePath, request); } return resources; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy