本文整理匯總了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";
}