The method getparameter(String) is undefined for the type HttpServletRequest
<@ page contentType ="test/html;charset=gb2312" language="java" import='java.*.*'%>
<%!
public String codeToString(String str){
String tempString = str;
try{
byte tempB[] = tempString.getBytes("ISO-8859-1");
tempString = new String(tempB);
return tempString;
}catch (Exception e){
return tempString;
}
}
%>
<html>
<body>
<form name = "form1" action = "chineseStringExample1.jsp" method="post">
请输入你的姓名(please enter your name):
<input type="text" name="username"/>
<input type="submit" name="sbmit" value="提交"/>
</form><br>
<%
if(request.getparameter("username")==null){
out.println("你还没有输入姓名");
out.println("You haven't entered your name!");
}
else{
out.println("你的姓名为(Your name is):"+codeToString(request.getParameter("username")));
}
%>
</body>
</html>
查了很久,才发现我这个是大小写写错了,是getParameter(),P要大写,下面是查到的没写错的其他解决方法