public class GetRequestParameterAction extends ActionSupport {
private String bookName;
private String bookprice;
public String getBookName() {
return bookName;
}
public void setBookName(String bookName) {
this.bookName = bookName;
}
public String getBookprice() {
return bookprice;
}
public void setBookprice(String bookprice) {
this.bookprice = bookprice;
}
public String execute() throws Exception{
System.out.println("bookName: "+this.bookName);
System.out.println("bookPrice: " +this.bookprice);
ActionContext context=ActionContext.getContext();
Map<K, V> parameterMap=context.getParameters();
String bookName2[]=parameterMap.get("bookName");
String bookPrice2[]=(String[])parameterMap.get("bookprice");
System.out.println("bookName: " +bookName2[0]);
System.out.println("bookPrice: " +bookPrice2[0]);
HttpServletRequest request = (HttpServletRequest)context.get(ServletActionContext.HTTP_REQUEST);
String bookName=request.getParameter("bookName");
String bookPrice=request.getParameter("bookPrice");
System.out.println("bookName: " +bookName);
System.out.println("bookPrice: " +bookPrice);
return SUCCESS;
}
}