1. 搭建struts2 的步驟: 3個步驟java
2. action VS Action shell
package strutshelloworld;
public class Product {
private Integer productId;
private String productName;
private String productDesc;
private double productPrice;
public Integer getProductId() {
return productId;
}
public void setProductId(Integer productId) {
this.productId = productId;
}
public String getProductName() {
return productName;
}
public void setProductName(String productName) {
this.productName = productName;
}
public String getProductDesc() {
return productDesc;
}
public void setProductDesc(String productDesc) {
this.productDesc = productDesc;
}
public double getProductPrice() {
return productPrice;
}
public void setProductPrice(double productPrice) {
this.productPrice = productPrice;
}
@Override
public String toString() {
return "Product [productId=" + productId + ", productName=" + productName + ", productDesc=" + productDesc
+ ", productPrice=" + productPrice + "]";
}
public String save(){
System.out.println("save: " + this);
return "details";
}
}
<form action="product-save.action" method="post">
productName: <input type="text" name="productName"/>
<br><br>
productDesc: <input type="text" name="productDesc"/>
<br><br>
productPrice: <input type="text" name="productPrice"/>
<br><br>
<input type="submit" name="Submit"/>
<br><br>
</form>
<action name="product-input" class="com.opensymphony.xwork2.ActionSupport" method="execute"> <result name="success" type="dispatcher">/WEB-INF/pages/input.jsp</result> </action>
3. 在Action 中訪問WEB 資源:安全
5. result:session