本文整理汇总了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;
}
示例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();
}
示例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;
}
}
示例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";
}