gpt4 book ai didi

java - jsp文件编译错误 "cannot find symbol: variable a location: class simplyfiedJSPServlet"

转载 作者:太空宇宙 更新时间:2023-11-04 06:25:54 24 4
gpt4 key购买 nike

我正在尝试学习 session 隐式对象。请检查。在 index.jsp 中,我创建了一个表单。单击提交按钮后,它将重定向到 welcome.jsp。在 welcome.jsp 中,我创建 session 属性,并在同一页面中重定向到 second.jsp。在 Second.jsp 中,我们将通过 session 获取名称。但在 welcom.jsp 文件中出现错误。找不到符号:变量位置:类 simplefiedJSPServlet

enter image description here

index.jsp

 <%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1> This for getting session implicit object </h1>
<form action="welcome3.jsp">
<input type="text" name="uname">
<input type="submit" value="go"><br/>
</form>
</body>
</html>

欢迎.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
String name=request.getParameter("uname");
out.print("Welcome"+name);
session.setAttribute("user", name);
<a href ="second.jsp" > second jsp </a>
%>
</body>
</html>

第二个.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
String name=(String )session.getAttribute("user");
%>
</body>
</html>

web.xml

<web-app>
<error-page>
<error-code> 500</error-code>
<location> /error.jsp</location>
</error-page>
</web-app>

最佳答案

你在java代码中有html标签,

     <% 
String name=request.getParameter("uname");
out.print("Welcome"+name);
session.setAttribute("user", name);
<a href ="second.jsp" > second jsp </a> // html anchor tag
%>

应该在它之外,

<a href ="second.jsp" > second jsp  </a>

what are scriptlets in jsp?

关于java - jsp文件编译错误 "cannot find symbol: variable a location: class simplyfiedJSPServlet",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26798485/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com