What is the best way to convert String to Integer.
params.get("contractPriceId");
here I am getting Exception cannot cast Integer to String...
public List<ContractPriceDetailVO> getContractPriceDetails(
Map<String, String> params) throws DAOException {
// Get the request object
HttpServletRequest request = FlexContext.getHttpRequest();
// Get the AppContext object
AppContext ac = SessionUtils.getAppContext(request);
SimpleDateFormat sdf = new SimpleDateFormat(ac.getDateFormat());
List<Object[]> resultList = new ArrayList<Object[]>();
if (params.get("specId") != null && params.get("specId").trim() != ""
&& params.get("effDate") != null
&& params.get("effDate").trim() != null)
resultList = contractPriceEJBService.getContractPriceDetails(ac,
params);
String contractPriceId = null;
if (params.get("contractPriceId") != null){
try{
contractPriceId = params.get("contractPriceId");
}
catch (Exception e){
logger.error("Exception in getting contractPriceId "+e.getMessage());
}
}
else{
contractPriceId = null;
}
Which exception are you getting ?
Normally we use,
int price = Integer.parseInt("7");
This returns the int value of string.
Please put the exception and error in the question so we can do more analysis of issue.
像这样改变它,它应该可以工作
contractPriceId = params.get("contractPriceId") +"";
From Integer to String, String.valueOf(47).
From String to Integer, Integer.parseInt("47").
To avoid the exception, try String.valueOf(params.get("contractPriceId")).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.