當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpServletRequest.getIntHeader方法代碼示例

本文整理匯總了Java中javax.servlet.http.HttpServletRequest.getIntHeader方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpServletRequest.getIntHeader方法的具體用法?Java HttpServletRequest.getIntHeader怎麽用?Java HttpServletRequest.getIntHeader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.servlet.http.HttpServletRequest的用法示例。


在下文中一共展示了HttpServletRequest.getIntHeader方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: constructBaseUrl

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
protected String constructBaseUrl(HttpServletRequest request) {
  String scheme = request.getScheme();
  if (request.getHeader("x-forwarded-proto") != null) {
    scheme = request.getHeader("x-forwarded-proto");
  }
  int serverPort = request.getServerPort();
  if (request.getHeader("x-forwarded-port") != null) {
    try {
      serverPort = request.getIntHeader("x-forwarded-port");
    } catch (NumberFormatException e) {
    }
  }

  String baseUrl = String.format("%s://%s:%d", scheme, request.getServerName(), serverPort);
  return baseUrl;
}
 
開發者ID:osswangxining,項目名稱:iotplatform,代碼行數:17,代碼來源:BaseController.java

示例2: doPost

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
/**
 * Returns a resource object as a result of a get request.
 **/
protected void doPost( HttpServletRequest req, HttpServletResponse resp ) throws ServletException, IOException {
    int length = req.getIntHeader( "Content-length" );
    String contentType = req.getHeader( "Content-type" );
    resp.setContentType( contentType );

    InputStreamReader isr = new InputStreamReader( req.getInputStream() );
    BufferedReader br = new BufferedReader( isr );
    resp.getWriter().print( length );

    String line = br.readLine();
    while (line != null) {
        resp.getWriter().print( "\n" );
        resp.getWriter().print( line );
        line = br.readLine();
    }
    resp.getWriter().flush();
    resp.getWriter().close();
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:22,代碼來源:StatelessTest.java

示例3: getRequestedDepth

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
private int getRequestedDepth(HttpServletRequest req)
{
	// Request has a depth value which describes how many levels
	// of propeties need to be returned. The default is INFINITY, but
	// usually it is only 1.
	try
	{
		return req.getIntHeader("Depth");
	}
	catch( Exception e )
	{
		// Depth = Infinity
		return Integer.MAX_VALUE;
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:16,代碼來源:WebdavServlet.java

示例4: addItem

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
@RequestMapping(value = "/addItem", method = RequestMethod.POST)
public String addItem(ModelMap map, HttpServletRequest request) {

    int id = request.getIntHeader("ID");
    String name = request.getParameter("name");
    String dop = request.getParameter("dop");
    float price = Float.parseFloat(request.getParameter("price"));
    String notes = request.getParameter("notes");

      ItemCreation i = new ItemCreation(id, name, dop, price, notes);
      dao.addItem(i);
      
      return "addItem";
}
 
開發者ID:coenribbens,項目名稱:Storage-System,代碼行數:15,代碼來源:DefaultController.java


注:本文中的javax.servlet.http.HttpServletRequest.getIntHeader方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。