为了账号安全,请及时绑定邮箱和手机立即绑定

求大神看看错误在哪里

求大神看看错误在哪里

qq_Forever永恒452_04175584 2016-12-07 08:07:50
import java.io.IOException;import java.io.PrintWriter;import java.io.UnsupportedEncodingException;import javax.servlet.RequestDispatcher;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;public class LoginServlet extends HttpServlet{ @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.setContentType("text/html;charset=\"utf-8\""); PrintWriter out = resp.getWriter(); //获取从登录界面传递过来的参数值 /* * 在此添加获取username和password值的语句 */ String action = req.getParameter("action"); //这里是新加的代码 String username = req.getParameter("username"); String password = req.getParameter("password"); String action =  req.getParameter("action"); if (action != null) { /* * 在此添加判断登录的条件 */ if ( username.equals("admin")&&password.equals("123456")) { printContent(out); }  } //获取点击了左侧导航栏链接时传递过来的值 String list = req.getParameter("list"); if (list != null) { /* *  在此添加 点击了主页后执行的操作 */ if (list.equals("homepage")) { out.println("<html>"); out.println("<h1>梁华</h1>"); out.println("<img src='1.jpg'>"); out.println("</html>"); } } } @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { doPost(req, resp); } private void printContent(PrintWriter out) { out.println("<html>"); out.println("<frameset cols='120,*'>"); out.println("<frame noresize='noresize' src='content/navlist.html'>"); out.println("<frame src='content/frameContent/ziliao.html' name='mainframe'>"); out.println("</frameset>"); out.println("</html>"); }}
查看完整描述

1 回答

已采纳
?
weibo_安然_无恙_80_0

TA贡献2条经验 获得超3个赞

是否重复定义一个同名的局部变量:action?
查看完整回答
1 反对 回复 2016-12-07
  • 1 回答
  • 0 关注
  • 1225 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信