Commit 01f7cfc1 authored by Matija Obreza's avatar Matija Obreza

Configure Spring MVC path matcher (fixes #30)

parent 102a6617
......@@ -30,6 +30,7 @@ import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
......@@ -48,7 +49,7 @@ public class NewsController extends BaseController {
@Autowired
private JspHelper jspHelper;
@RequestMapping(value = "/content/news", method = RequestMethod.GET)
@GetMapping(value = "/content/news")
public String getAllNews(ModelMap model, @RequestParam(value = "page", defaultValue = "1") int page) {
Page<ActivityPost> allNews = contentService.allNews(page);
......@@ -59,7 +60,7 @@ public class NewsController extends BaseController {
}
@RequestMapping(value = "/content/news/{id:.+}/{title:.+} ", method = RequestMethod.GET)
@GetMapping(value = "/content/news/{id}/**")
public String getNewsById(@PathVariable("id") Long id, Model model) throws Exception {
ActivityPost activityPost = contentService.getActivityPost(id);
......
......@@ -38,9 +38,9 @@ import org.springframework.context.support.ResourceBundleMessageSource;
import org.springframework.validation.Validator;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer;
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.handler.SimpleMappingExceptionResolver;
......@@ -146,6 +146,13 @@ public class SpringServletConfig extends WebMvcConfigurerAdapter {
configurer.favorPathExtension(false);
}
@Override
public void configurePathMatch(PathMatchConfigurer configurer) {
configurer.setUseTrailingSlashMatch(true);
configurer.setUseSuffixPatternMatch(false);
configurer.setUseRegisteredSuffixPatternMatch(false);
}
// /**
// * http://stackoverflow.com/questions/16332092/spring-mvc-pathvariable-with-dot-is-getting-truncated
// */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment