Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
java
java
public class JAXRSUserModelServlet extends CXFNonSpringJaxrsServlet  {

    @Override
    public void loadBus(ServletConfig servletConfig) throws ServletException {
        super.loadBus(servletConfig);

        JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
        String address = servletConfig.getInitParameter(SERVICE_ADDRESS_PARAM); //jaxrs.address
        if (address == null) {
            address = "/";
        }
        sf.setAddress(address);

        // modelRef needs to start from 'classpath:', ex 'classpath:/WEB-INF/models/model1.xml
        String modelRef = servletConfig.getInitParameter("user.model");
        sf.setModelRef(modelRef);
        sf.create();
    }
} 

Query String

...

Customization

CXF provides advanced capabilities with respect to query string parsing and expansion.

Collection/List

The typical way to manage collection/list query parameters is described in RFC-6570: URI Template (https://tools.ietf.org/html/rfc6570) and basically assumes the repetition of the name/value pairs, for example: http://localhost:8080/MovieDB/GetJson?name=Actor1&name=Actor2&name=Actor3&startDate=20120101&endDate=2012050

Since 3.1.8+, this behavior could be tweaked using server-side "parse.query.value.as.collection" property,  which adds support for collection/list parameters passed as comma-separated values, , for example: http://localhost:8080/MovieDB/GetJson?name=Actor1,Actor2,Actor3&startDate=20120101&endDate=2012050