gpt4 book ai didi

java - org.apache.jasper.JasperException : An exception occurred processing JSP page/editinfo. jsp

转载 作者:搜寻专家 更新时间:2023-10-31 08:04:34 24 4
gpt4 key购买 nike

我有这个 jsp 代码,我试图在我的网页上为用户编辑信息。我是 jsp 编程的新手,我遇到了错误。这是我的代码:

<%@page import="DatabaseTransactions.UserPhotosDataContext"%>
<%@page import="java.sql.ResultSet"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
if (session.getAttribute("id") == null) {
response.sendRedirect(request.getContextPath() + "/sign-in.jsp");
}

int userId = Integer.parseInt(session.getAttribute("id").toString());
ResultSet userInfo = UserPhotosDataContext.getUserProfileInfo(userId);
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Edit Information</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
<link href="styles.css" rel="stylesheet">
</head>

<body class="bodybg">
<jsp:include page="/navigation.jsp"/>
<% userInfo.next();%>

<div class="boxouter" style="margin-top:50px;">
<h3 class="muted">Edit Information</h3>
<!--- more code here---->

<br><br>
<form id="update-form" method="" action="">
<table style="margin:auto">
<tr>
<!--username-->
<td>
<label>Username <span id="uname-error" class="form-error"></span></label>
<input type="text" title="Use at least 6 characters"
name="username" id="uname"
value="<%=userInfo.getString("username")%>"
placeholder="Username" disabled="true">
</td>

<!--email-->
<td>
<label>Email <span id="email-error" class="form-error"></span></label>
<input type="text"
name="email" id="email"
value="<%=userInfo.getString("email")%>"
placeholder="Email" disabled="true">
</td>
</tr>

<!--- more code here---->

</table>

<center/>
<button class="btn btn-info" onclick="enablefields();" id="enablebtn" style="visibility:visible">Edit Information</button>

<a id="savelink" href="#" style="color:white;">
<button class="btn btn-info" id="savebtn" type="submit" style="visibility:hidden">Save</button>
</a>

<a href="#" style="color:white">
<button class="btn btn-info" id="deactivatebtn" style="visibility:visible">Deactivate Account</button>
</a>
</form>
</div>
</div>


<br><br>

<!--- more code here---->

<script type="text/javascript">
function setValues() {
if ("<%=userInfo.getString("gender")%>" == "Male")
$('select option:contains("Male")').prop('selected',true);

else if ("<%=userInfo.getString("gender")%>" == "Female")
$('select option:contains("Female")').prop('selected',true);
}

window.onload = setValues;

</script>

<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/bootstrap.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/bootstrap.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/bootstrap-modal.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/bootstrap-popover.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/bootstrap-modalmanager.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/editinfo.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/holder.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/logout.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/bootstrap-dropdown.js"></script>
</body>
</html>

当我运行它时,我得到这个错误:

org.apache.jasper.JasperException: An exception occurred processing JSP page /editinfo.jsp at line 61

第 61 行是:

value="<%=userInfo.getString("email")%>"

我删除了这一行,它工作得很好(但我需要它来获取值)。当我保留第 61 行并尝试删除它时:

value="<%=userInfo.getString("username")%>"

在我页面的第 52 行,它仍然不起作用。

我还将第 52 行替换为第 61 行并且它有效。

我也遇到了这些错误:

javax.servlet.ServletException: java.sql.SQLException: Column 'email' not found. java.sql.SQLException: Column 'email' not found.

但我 100% 确定我的数据库有一个电子邮件列。此外,当我对数据库的其他列尝试此操作时,它会返回相同的错误。仅当它是“用户名”列时才有效。请帮我。我该如何解决这个问题?

最佳答案

表达式标签表示<%= .......>

在表达式末尾使用分号 (;)

value='<%= userInfo.getString("email") ; %>'

我希望它能奏效,请试试这个。

关于java - org.apache.jasper.JasperException : An exception occurred processing JSP page/editinfo. jsp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18122530/

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