gpt4 book ai didi

java - 改变背景颜色jsp

转载 作者:行者123 更新时间:2023-11-30 10:09:43 25 4
gpt4 key购买 nike

Previously asked a question对这个。当我运行代码时 - 我在表达式中遇到错误:

org.apache.jasper.JasperException: An exception
occurred processing JSP page [/apps.jsp] at line [15]

12: <input type="button" name="red" value ="red" >
13: <%
14: String button1Click = request.getParameter("red");
15: if(button1Click.equals("red")){
16: %>
17: <body style='background-color: red;'>
18: <%

我该如何解决?所有代码

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action = "apps" method="POST">
<input type="button" name="red" value ="red" >
<%
String button1Click = request.getParameter("red");
if(button1Click.equals("red")){
%>
<body style='background-color: red;'>
<%
}

%>

<input type="submit" name="blue" value ="blue" >
<input type="submit" name="green" value ="green" >
<input type="submit" name="yellow" value ="yellow" >
<input type="submit" name="reset" value ="reset" >
</form>
</form>
</body>
</html>

最佳答案

这可能是因为 NullPointerException .尝试

if(button1Click != null && button1Click.equals("red"))

替换<body></header> 之后标记用您的整个 Java 代码标记。

关于java - 改变背景颜色jsp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53112066/

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