我有以下JSP:



<jsp:useBean id="trackingBean" class="tracking.Tracking" scope="session">
    <jsp:setProperty name="trackingBean" property="*" />
</jsp:useBean>

<form action="TrackingController" method="post">


    <div id="upper_frequency">
        Upper Freq: <input type="text" name="upperFreq"

        >
    </div>
    <div id="lower_frequency">
        Lower Freq: <input type="text" name="lowerFreq"
        >
    </div>
    <div id="if_frequency">
        IF Freq: <input type="text" name="ifFreq"
        >
    </div>
    <div id="cap_high">
        Tuning Cap highest value: <input type="text" name="capHigh"
        >
    </div>
    <div id="cap_low">
        Tuning Cap lowest value: <input type="text" name="capLow"
        >
    </div>


    <input type="submit" value="Submit" />

</form>




这应该将trackingBean传递给其doGet的sevlet,与doPost相同:

doGet..
{
         Tracking trackingBean = (Tracking) request.getSession(),getAttribute("tackingBean");

....

}


trackingBrean不为null,但从未设置所有值吗?

Bean是:

  package tracking;

public class Tracking {

    public Tracking() {

}

private double upperFreq;
private double lowerFreq;
private double ifFreq;
private double capHigh;
private double capLow;
public double getUpperFreq() {
    return upperFreq;
}
public void setUpperFreq(double upperFreq) {
    this.upperFreq = upperFreq;
}
public double getLowerFreq() {
    return lowerFreq;
}
public void setLowerFreq(double lowerFreq) {
    this.lowerFreq = lowerFreq;
}
public double getIfFreq() {
    return ifFreq;
}
public void setIfFreq(double ifFreq) {
    this.ifFreq = ifFreq;
}
public double getCapHigh() {
    return capHigh;
}
public void setCapHigh(double capHigh) {
    this.capHigh = capHigh;
}
public double getCapLow() {
    return capLow;
}
public void setCapLow(double capLow) {
    this.capLow = capLow;
}


}

最佳答案

您正在请求“ tackingBean”,您是否需要“ trackingBean”?

关于java - 将bean传递给servlet,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25182986/

10-10 12:26