CSS 小脚本中的标签

CSS tags in scriptlets

我需要设置一个ID,因为我想分离代码形式样式。这是代码:

        <table class="form">
            <tr>
                <td class="InitialPadding">
                    <% if (message.equals("DATABASE ALREADY EXIST")){
                        out.print("<font color='red'>"+message);
                    }
                    else{
                        out.print("<font color='green'>"+message);
                    }

                    %>
                </td>
            </tr>
        </table>

包含颜色的 CSS 在 css 文件中,这是层次结构:

--Web Pages
     -css
         global.css //THIS IS THE CSS FILE
     -images
         background.jpg

     -index.html
     -install.html  //THIS IS WHERE THE SCRIPTLET IS
--Source Packages
--etc

如何在输出打印中设置使用 ID,如下所示:

  out.print("<id="error">"+message);

而不是:

out.print("<font color='red'>"+message);

谢谢。

  1. 为元素指定类型。
  2. 不要在用双引号分隔的变量中使用双引号

这样的:

out.print("<p id='error'>" + message);