更改bg颜色jsp [英] Change bg color jsp

查看:149
本文介绍了更改bg颜色jsp的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以前曾问过这个问题.当我运行代码时-表达式中出现错误:

Previously asked a question about this. When I run the code - I get an error in the expression:

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: <%

我该如何解决?所有代码

How can I fix it? All code

<%@ 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造成的.试试

It's probably because of a NullPointerException. Try

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

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

Replace <body> tag after </header> tag with your whole java code.

这篇关于更改bg颜色jsp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆