【Java】@Produces註解翻譯__Java

來源:互聯網
上載者:User

import javax.ws.rs.Produces;

/* * Produces.java * Created on September 15, 2006, 2:40 PM */package javax.ws.rs;import java.lang.annotation.ElementType;import java.lang.annotation.Inherited;import java.lang.annotation.Retention;import java.lang.annotation.RetentionPolicy;import java.lang.annotation.Target;/** * Defines the media type(s) that the methods of a resource class or * {@link javax.ws.rs.ext.MessageBodyWriter} can produce. * If not specified then a container will assume that any type can be produced. * Method level annotations override a class level annotation. A container * is responsible for ensuring that the method invoked is capable of producing * one of the media types requested in the HTTP request. If no such method is * available the container must respond with a HTTP "406 Not Acceptable" as * specified by RFC 2616. * * <p>A method for which there is a single-valued <code>Produces</code> * is not required to set the media type of representations that it produces: * the container will use the value of the <code>Produces</code> when * sending a response.</p> * * @see javax.ws.rs.ext.MessageBodyWriter *///定義了資源類型或者MessageBOdyWriter的媒體類型產生方法;如果沒有特別聲明,那麼一個容器會認定任何類型都可以被生產;//方法的註解層級重寫了類註解層級;一個容器會為保證被引用的方法而負責,從而能夠生產一個HTTP請求中的請求媒體類型。如果沒有這樣一個方法,容器會響應HTTP一個“406 Not Acceptable”資訊;//一個有單值的Produces的方法不會被要求設定代表他生產的媒體類型:當發送response請求的時候,容器會使用Produces的值。詳情請見javax.ws.rs.ext.MessageBodyWriter@Inherited@Target({ElementType.TYPE, ElementType.METHOD})@Retention(RetentionPolicy.RUNTIME)public @interface Produces {    /**     * A list of media types. Each entry may specify a single type or consist     * of a comma separated list of types. E.g. {"image/jpeg,image/gif",     * "image/png"}. Use of the comma-separated form allows definition of a     * common string constant for use on multiple targets.     * 一系列的媒體類型。每一個入口可能特別規定了一個單獨類型或者用逗號隔開一系列類型;例如{"image/jpeg,image/gif",     * "image/png"}     * 使用逗號分隔的形式允許定義一個普通的string類型的常量,來使用多媒體目標     */    String[] value() default "*/*";    }

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.