質問

hello! I have this url www.someurl.jsp?param=1 and i want to store the 1 into a variable

i wrote this

<% int r=request.getParameter("param");%>

and i have an error "incompatible types ,required:int, found:String" i wrote then this

<% int r= (int) request.getParameter("param");%>

but it doesnt work also...

役に立ちましたか?

解決 2

request.getParameter("param") will return String.So you need to convert it to int.For that you need to do typecasting

like

<% int r=Integer.parseInt(request.getParameter("param"));%>

他のヒント

You need to use parseInt

<% int r=Integer.parseInt(request.getParameter("param"));%>
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top