首页 > 编程知识 正文

servlet获取request,java中scanner报错

时间:2023-05-04 09:50:52 阅读:25657 作者:2017

此错误只对IDEA有问题,eclipse不会出现此问题。

有教迷津的前辈吗?

publicclassservletdemo 02扩展http servlet {

私有状态长时间服务版本=1l;

公共语音文档(httpservletrequestrequest,http servlet响应) throws ServletException,IOException {

doget (请求,响应);

}

公共语音文档(httpservletrequestrequest,http servlet响应) throws ServletException,IOException {

//获取与客户端提交给服务端的method对应的值

string MD=request.getparameter (' method );

//定义变量,保存功能执行后传输的路径

字符串路径=null;

//获取当前字节码对象(ServletDemo02.class位于内存中的对象) ) )。

Class clazz=this.getClass (;

try {

获取clazz上名称为md的方法

方法方法=clazz.get方法(MD,HttpServletRequest.class,HttpServletResponse.class );

if (空!=method

//调用找到的方法

path=(string ) method.invoke ) this,request,response;

}

if (空!=path )

//服务器端传输

request.getrequest dispatcher (path ).forward ) request,response;

}

}catch(exceptione ) {

e .打印堆栈跟踪(;

}

}

publicstringaddstu (httpservletrequestrequest,HttpServletResponse response ) throws ServletException,IOException {

System.out.println ('添加学生');

return '/test.html ';

}

}

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。