我想在jsp中显示预先填充的表单。
TestAction.java
import com.opensymphony.xwork2.ActionSupport;
public class TestAction extends ActionSupport {
private String firstName;
private String lastName;
public String execute(){
setFirstName("John");
setLastName("Doe");
return SUCCESS;
}
/** Getters & Setters **/
}
当我使用html标签时,它没有这样做,
test.jsp的
<!DOCTYPE html>
<html>
<head></head>
<body>
<form>
First Name <input type="text" name="firstName" > <br/>
Last Name <input type="text" name="lastName">
</form>
</body>
</html>
当我使用struts2标签时,它工作正常。
<s:form>
<s:textfield name="firstName"></s:textfield>
<s:textfield name="lastName"></s:textfield>
</s:form>
可以使用非struts2标签实现吗?
答案 0 :(得分:1)
您可以使用JSP EL
public void TrainLVQ(int maxEpoch, double minLearningRate){
euclideandistance = new double[numberofcluster];
System.out.print("Training LVQ");
int epoch = 0;
while(epoch <= maxEpoch || learnigRate >= minLearningRate)
epoch = epoch +1;
for(int k=0;k<numberofinput;k++){
//Get the winning neuron
winningneuron = 0;
for(int i=0;i<numberofcluster;i++){
euclideandistance[i] = ComputeEuclideanDistance(bobot[i],inputVector[k]);
if(i!=0){
if(euclideandistance[i]<euclideandistance[winningneuron]){
winningneuron = i;
}
}
//System.out.println(euclideandistance[i]);
}
if(targetcluster[k] == winningneuron){
for(int i=0;i<inputdimension;i++){
bobot[winningneuron][i] += learnigRate * (inputVector[k][i] - bobot[winningneuron][i]);
}
}
else{
for(int i=0;i<inputdimension;i++){
bobot[winningneuron][i] = bobot[winningneuron][i] - (learnigRate * (inputVector[k][i] - bobot[winningneuron][i]));
}
}
//System.out.println("Winner:"+winningneuron);
//Update the winning neuron
}
learnigRate = learnigRate * minLearningRate;
System.out.print(".");
//System.out.println("Learn Rate:"+learnrate);
}
}
值是字符串,因此为了安全起见,最好逃避它们。
如果此jsp作为操作的结果返回,则变量以及标准范围也会搜索值堆栈。应该可以从值堆栈中获取操作属性。