gpt4 book ai didi

java - 实现静态方法 - 需要帮助

转载 作者:行者123 更新时间:2023-12-01 19:07:09 25 4
gpt4 key购买 nike

开发一个网络应用程序并实现一个名为“计算器”的类,该类可以计算有关您 body 的某些信息,以确定如何集中饮食。

我正在实现这个计算器,但出现错误。这是错误;下面是源代码的示例。如果您能告诉我问题出在哪里,我将不胜感激。

错误:

org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 83 in the jsp file: /updateProfile.jsp
Calculator cannot be resolved
80: a6 = "checked";
81: }
82:
83: out.println(Calculator.percentBodyFat("f","145","38","38","38","27","27","27",67.0,"6.5"));
84:
85: String theName = request.getParameter("name");
86: if(theName != null)


Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:102)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:331)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:457)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:378)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

源代码:

import java.io.BufferedReader;
package hygeia;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Scanner;

public class Calculator {

public static double percentBodyFat(String sex, String w, String h1,
String h2, String h3, String a1, String a2, String a3, double height, String wr)
{
//statements
}
public static double leanBodyMass(double weight, double percentBodyFat)
{
//statements
}
public static double protein(double leanBodyMass, int activLevel)
{
//statements
}
}

它能够编译,但我无法让它与 jsp 一起工作。看起来应该很简单。

最佳答案

您必须在 JSP 页面中包含 Calculator

<%@page import="Calculator"%> <%-- with the complete package of Calculator class--%>

关于java - 实现静态方法 - 需要帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9631646/

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