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值的语句 */ if (action != null) { /* * 在此添加判断登录的条件 */ if ( ) { printContent(out); } } //获取点击了左侧导航栏链接时传递过来的值 String list = req.getParameter("list"); if (list != null) { /* * 在此添加 点击了主页后执行的操作 */ if (list.equals("homepage")) { } } } @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>"); }}
2 回答
Frank_W毅3947945
TA贡献6条经验 获得超3个赞
兄弟,你jsp页面是什么,传递过来的是什么值?判断的登录条件是什么?你得说的具体一点啊。。
//大致猜测jsp页面设置的name,下面是获得username,password String username=req.getParameter("username"); String password=req.getParameter("password"); 其他不好写,你都没把问题说明白
添加回答
举报
0/150
提交
取消