<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%@ page import="com.bjsxt.login.User" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
if("xiaogao".equals(name) && "123".equals(pwd)){
User user = new User(name,pwd);
session.setAttribute("user12", user);
pageContext.forward("login_ok.jsp");
return;
}else{
request.setAttribute("loginError", "用户名或者密码错误");
pageContext.forward("login.jsp");
return;
}
%>
报错信息如下:
An error occurred at line: 34 in the jsp file: /handleLogin.jsp
Unreachable code
31: pageContext.forward("login.jsp");
32: return;
33: }
34: %>
35:
36:
严重: Servlet.service() for servlet [jsp] in context with path [/TestWeb] threw exception [Unable to compile class for JSP:
An error occurred at line: 34 in the jsp file: /handleLogin.jsp
Unreachable code
31: pageContext.forward("login.jsp");
32: return;
33: }
34: %>
35:
36:
把%>后面的回行和空格去掉就好了, 或者是去掉最后的return
不需要return吧。
Unreachable code,因为return导致有代码执行不了。