我想使用 java 类更改这些文本区域的属性。如您所见,textareas 默认情况下是禁用的。如果用户在数据库中找不到注册的 TIN,我希望启用此功能。这是我的代码:
jsp:
<label style="font-size: 17px;">Registered Name</label><br><br>
<textarea disabled id="tpName" name="tpName" style="margin-top: -9px; width: 275px; height: 40px;">${name}</textarea>
<br><br>
<label style="font-size: 17px;">Address</label><br><br>
<textarea disabled id="tpAddress" name="tpAddress" style="margin-top: -9px; width: 275px; height: 40px;">${address}</textarea>
班级:
private String tpTin;
private String tpName;
private String tpAddress;
private TblTaxPayment tbltaxpayment;
public String getTpTin() {
return tpTin;
}
public String getTpName() {
return tpName;
}
public String getTpAddress() {
return tpAddress;
}
public void setTpTin(String tpTin) {
this.tpTin = tpTin;
}
public void setTpName(String tpName) {
this.tpName = tpName;
}
public void setTpAddress(String tpAddress) {
this.tpAddress = tpAddress;
}
private HttpServletRequest request;
public void setServletRequest(HttpServletRequest request){
this.request = request;
}
public TblTaxPayment getTblTaxPayment() {
return tbltaxpayment;
}
public void setTblTaxPayment(TblTaxPayment tbltaxpayment) {
this.tbltaxpayment = tbltaxpayment;
}
@SuppressWarnings("unused")
public String execute() throws Exception {
Debugger.border();
Debugger.startDebug(this.getClass().toString());
String tax = request.getParameter("tpTin");
TblTaxPaymentDAO tdao = DAOFactory.getDaoManager(TblTaxPayment.class);
TblTaxPayment t = null;
t = tdao.findbyTIN(tax.replace("-", ""));
tbltaxpayment = (TblTaxPayment) t;
try{
Debugger.print("TIN : "+tax);
if(tax != null) {
tpTin = tbltaxpayment.getTpTin();
tpName = tbltaxpayment.getTpName();
tpAddress = tbltaxpayment.getTpAddress();
String tin = tpTin;
String name = tpName;
String address = tpAddress;
request.setAttribute("tin", tin);
request.setAttribute("name", name);
request.setAttribute("address", address);
return SUCCESS;
}else{
request.setAttribute("name", true);
request.setAttribute("address", true);
return SUCCESS;
}
}catch(Exception e){
e.printStackTrace();
Debugger.endDebug(this.getClass().toString());
Debugger.border();
return ERROR;
}
}
}
我做了什么。我将属性设置为 true 以便能够更改 jsp 中 textareas 的属性/属性。