Skip to content

Instantly share code, notes, and snippets.

@circlee
Created June 29, 2017 07:54
Show Gist options
  • Save circlee/28e9372643a02df508fd20ddd3eb4137 to your computer and use it in GitHub Desktop.
Save circlee/28e9372643a02df508fd20ddd3eb4137 to your computer and use it in GitHub Desktop.
SPA requestMapping
import javax.inject.Inject;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import com.glowpick.ec.api.product.service.DisplayService;
import lombok.extern.slf4j.Slf4j;
@Controller
@Validated
@Slf4j
public class TestController {
@RequestMapping("/")
public String getIndex( HttpServletRequest request, HttpServletResponse response){
response.addCookie(new Cookie("TEST", "it's a test"));
return "/index.html";
}
@RequestMapping(
{
"{path:(?!index\\.html|swagger-ui\\.html).*$}"
, "{path:(?!index\\.html|swagger-ui\\.html|webjars|static).*}/**"
}
)
public String getIndex( HttpServletRequest request, HttpServletResponse response, @PathVariable("path") String path){
System.out.println(path);
return getIndex(request, response);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment