Announcement Announcement Module
Collapse
No announcement yet.
trailing slash in tomcat Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • trailing slash in tomcat

    all,

    under tomcat 6 on windows these urls work, with or with the trailing slash. -
    http://localhost:8080/magic/recommendation
    http://localhost:8080/magic/recommendation/

    http://localhost:8080/recommendation?sectionId=3
    http://localhost:8080/recommendation/?sectionId=3

    but under tomcat 7 on linux i can only get these to work -
    http://localhost:8080/magic/recommendation
    http://localhost:8080/recommendation?sectionId=3

    the trailing slash doesn't work. and i need it to for some dojo rest object stores.

    my controller looks like
    Code:
    @Controller
    @RequestMapping("/recommendation")
    public class RecommendationController extends BaseRESTController {
    
        @Resource RecommendationService _recommendationService;
    
    
        @RequestMapping(value="/{id}", method= RequestMethod.GET, headers=ACCEPT_JSON)
        public @ResponseBody RecommendationDTO get(@PathVariable("id") Long id) {
            return new RecommendationDTO(_recommendationService.getRecommendation(id));
        }
    
    
        @RequestMapping(value={"","/"}, method= RequestMethod.GET, headers=ACCEPT_JSON)
        public @ResponseBody List<RecommendationDTO> getAll() {
            List<RecommendationDTO> recommendationDTOs = new ArrayList<RecommendationDTO>();
            for(Recommendation recommendation : _recommendationService.getAllRecommendations()) recommendationDTOs.add(new RecommendationDTO(recommendation));
            return recommendationDTOs;
        }
    
    
        @RequestMapping(value={"","/"}, method= RequestMethod.GET, headers=ACCEPT_JSON, params="sectionId")
        public @ResponseBody List<RecommendationDTO> getBySectionId(@RequestParam("sectionId") Long sectionId) {
            List<RecommendationDTO> recommendationDTOs = new ArrayList<RecommendationDTO>();
            for(Recommendation recommendation :  _recommendationService.getByRecommendationSectionId(sectionId)) recommendationDTOs.add(new RecommendationDTO(recommendation));
            return recommendationDTOs;
        }
    i've try this with and without value={"","/"} in the method mapping.

    here's some web.xml
    Code:
        <context-param>
            <param-name>contextClass</param-name>
            <param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value>
        </context-param>
    
        <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>com.magic.config</param-value>
        </context-param>
        <filter>
            <filter-name>CharacterEncodingFilter</filter-name>
            <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
            <init-param>
                <param-name>encoding</param-name>
                <param-value>UTF-8</param-value>
            </init-param>
            <init-param>
                <param-name>forceEncoding</param-name>
                <param-value>true</param-value>
            </init-param>
        </filter>
    
        <filter-mapping>
            <filter-name>CharacterEncodingFilter</filter-name>
            <servlet-name>magic</servlet-name>
        </filter-mapping>
    
        <filter>
            <filter-name>oemInViewFilter</filter-name>
            <filter-class>
                org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter
            </filter-class>
        </filter>
    
        <filter-mapping>
            <filter-name>oemInViewFilter</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>
    
        <filter>
            <filter-name>HttpMethodFilter</filter-name>
            <filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
        </filter>
    
        <filter-mapping>
            <filter-name>HttpMethodFilter</filter-name>
            <servlet-name>magic</servlet-name>
        </filter-mapping>
    
        <filter>
            <filter-name>springSecurityFilterChain</filter-name>
            <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
        </filter>
    
        <filter-mapping>
            <filter-name>springSecurityFilterChain</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>
    
    
        <servlet>
            <servlet-name>magic</servlet-name>
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
            <init-param>
                <param-name>contextConfigLocation</param-name>
                <param-value></param-value>
            </init-param>
            <load-on-startup>2</load-on-startup>
        </servlet>
    
        <servlet-mapping>
            <servlet-name>magic</servlet-name>
            <url-pattern>/</url-pattern>
        </servlet-mapping>
    
        <servlet>
            <servlet-name>staticcontent</servlet-name>
            <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
            <load-on-startup>1</load-on-startup>
        </servlet>
    if i change the servlet mapping to /* then i can use /* in the controller mapping and things work but then spring security breaks.

    thanks
Working...
X