当前位置: 首页>>代码示例>>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;未经允许,请勿转载。