我正在使用以下 JSP 页面:
<%@page import="java.util.*" %>
<%
String[] colors = {"Gray", "Brown", "Red" , "Orange", "yellow", "Green", "Blue", "purple"};
String color, numero;
color=request.getParameter("colores");
numero=request.getParameter("numeros");
int c = Integer.parseInt(request.getParameter("colores"));
int num = Integer.parseInt(request.getParameter("numeros"));
%>
<HTML>
<BODY>
<TABLE BORDER="1" align="center" bgcolor="#E8FDFF" height="40%">
<TR>
<TD bgcolor="<%=colors[c-1] %>">
<% HERE GOES THE JAVA PART %>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
我想添加一个 java 类和方法,如下所示:
public class Tabla
{
public static void main (String[] args)
{
int n=67;
int j;
Tabla table = new Tabla ();
int dato[];
dato=table.producto(n);
for (j=0;j<10;j++)
{System.out.println(dato[j]);
}
}
public int [] producto(int num)
{
// make a 10-element array
int a[] = new int[10];
// fill up the array with products
for (int i = 0; i < 10; i++)
{a[i] = num * (i+1); }
return a;
}
}
我尝试将整个代码添加到 jsp 页面,但它不起作用。我不知道该怎么做。
我已经“搜索”了解决方案,人们谈论了一个类文件夹。我在我的 PC 中找到了用于 Apache Tomcat 的类文件夹,这是我正在使用的软件,但类文件有点“编码”,所以我想我没有做正确的事情。
任何关于我能做什么的建议或想法都会非常感激
提前致谢!