动态 web 服务器 servlet 输出问题

dynamic web server servlet problem with output

我的网络服务器有问题。我需要引入参数,然后在 class 的计算中引入该值。计算后我需要在按下确定按钮后显示该值

package CalculatorOnline;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/TestCalc")
public class TestCalc extends HttpServlet {
    private static final long serialVersionUID = 1L;

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        int  Prescale = Integer.parseInt(request.getParameter("prescaler"));
        int TimerMO = Integer.parseInt(request.getParameter("timermode"));
        long TTTicks = Integer.parseInt(request.getParameter("ttticks"));
        double  Freq = Integer.parseInt(request.getParameter("freq"));

        System.out.println("Frecventa:"+ Freq);
        System.out.println("Prescaler:"+ Prescale);
        System.out.println("TimerMod:"+ TimerMO);
        System.out.println("TotalTimerTicks"+ TTTicks);
        TestLabclass temp = new TestLabclass();
        temp.setFreq(Freq);
        temp.setPrescaler(Prescale);
        temp.setTTTicks(TTTicks);

        PrintWriter out = response.getWriter();
        double TimeU2 = temp.getTimeU();
        double RealT = temp.getRealT();

        out.println("Timpului pina la umplere : "+ TimeU2);
        out.println("Real time per tick : "+ RealT);
    }
}
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
    <form name="Frec input" action="TestLab">
           <p>  <label>FREQUENCY</label>
           <input type="number" name="freq" id="quantity" /> 
            <label>Total Timer Ticks</label>
           <input type="number" name="ttticks" id="quantity" /> 
            <label>Prescaler</label>
            <select name="prescaler">
                <option value="0">No clock source</option>
                <option value="1">No Prescaling</option>
                <option value="8">clkI/O/8</option>
                <option value="64">clkI/O/64</option>
                <option value="256">clkI/O/256</option>
                <option value="1024">clkI/O/1024</option>
            </select>
            <label>Mode</label>
            <select name="timermode">
                <option value="0">Normal</option>
                <option value="1">PWM</option>
                <option value="2">CTC</option>
                <option value="3">Fast PWM</option>
            </select>
           <input type="submit" value="ok" />
            </p>


        </form>
</body>
</html>

enter image description here

我正在介绍我需要的所有数据,按确定按钮后出现 404 错误。我的输出参数没有显示

class文件

package CalculatorOnline;

class TestLabclass {
        double Freq; // frequency
        double TimeU; // overflow time
        double RealT; //real time per tick
        int Prescaler;
        long TTTicks;
        long OverFlowCount;

        public TestLabclass()
        { 
            Freq = 0;
            TimeU = 0;
            RealT = 0;
            Prescaler = 0;
            TTTicks = 0;
            OverFlowCount = 0;
        }

        public double getFreq()
        {
            return Freq;    
        }

        public void setFreq(double Freq)
        {
            this.Freq = Freq;
        }

        public int getPrescaler()
        {
            return Prescaler;


        public void setPrescaler(int Prescaler)
        {
            this.Prescaler = Prescaler;
        }

        public long getTTTicks()
        {
            return TTTicks;
        }

        public void setTTTicks(long TTTicks)
        {
            this.TTTicks = TTTicks;
        }

        public double getRealT() {
            return TTTicks/(Freq/Prescaler);
        }

        public void setRealT(double RealT)
        {
            this.RealT = RealT;
        }

        public void setOverFlowCount(long OverFlowCount)
        {
            this.OverFlowCount = OverFlowCount;
        }

        public long getOverFlowCount()
        {
            return TTTicks/256;
        }

        public double getTimeU()
        {
            return RealT*(TTTicks - (OverFlowCount * 256));
        }

        public void setTimeU(double TimeU)
        {
            this.TimeU = TimeU; 
        }
}

形式 action 应与 @WebServlet("/TestCalc")

中声明的名称匹配

替换

<form name="Frec input" action="TestLab">

<form name="Frec input" action="TestCalc">

-或-

@WebServlet("/TestCalc")替换为@WebServlet("/TestLab")