servlet 中的响应映射

Response Mapping in servlet

响应映射在 Servlet 中如何工作?

每个响应如何知道清除特定 HTML 或车把上的输出?

有一个 ember-java github 个项目 Jersey REST Service

它使用扩展 HttpServletcom.sun.jersey.spi.container.servlet.ServletContainer。它 return 使用 ServletResponse 编写正文并调用 flush()

的输出

getOutputStream .. Calling flush() on the ServletOutputStream commits the response. Either this method or getWriter() may be called to write the body

如果您检查 servlet 中的特定服务,它 returns json 响应 (@Produces)

@Produces(MediaType.APPLICATION_JSON)
public Customers get(@QueryParam("ids[]") List<Long> ids) {
    if (ids != null && !ids.isEmpty()) {
        return new Customers(manager.findByIds(ids));
    }
    return new Customers(manager.findAll());
}

Ember 是使用适配器连接到 HTTP 服务器

The store uses an object called an adapter to know how to communicate over the network. By default, the store will use DS.RESTAdapter, an adapter that communicates with an HTTP server by transmitting JSON via XHR

ember-data.js 有适配器配置

DS.RESTAdapter = DS.Adapter.extend({ ...

router.js

中定义的return客户

App.Router.map(function() { this.resource("customers"); this.resource("customer", { path: '/customer/:customer_id' });

并且在 customer.hbs

中有客户模板