报错:Unhandled exception type UnsupportedEncodingException

private void update(HttpServletRequest request, HttpServletResponse response)
{
request.setCharacterEncoding("utf-8");
String name = request.getParameter("name");
String id = request.getParameter("id");
String sex = request.getParameter("sex");
String password = request.getParameter("password");
Bean bean =new Bean(id,name,password,sex);
daos.update(bean);
request.setAttribute("message", "修改成功");//进行请求转发时,需要把一些数据传递到转发后的页面,用---将参数保存在request范围内的变量中,第一个参数时变量名
request.getRequestDispatcher("serlet?method=list").forward(request, response);//请求转发
}

报错:Unhandled exception type UnsupportedEncodingException

原因:没加try catch,因为java是强类型语言,如果编译器发现你没有去处理可能抛出的异常,所以就产生语法错误。

对java 基础语法不熟悉

原文地址:https://www.cnblogs.com/ajinjinjin/p/14154998.html