searchaction.java~3~
来自「网上银行」· JAVA~3~ 代码 · 共 46 行
JAVA~3~
46 行
package prostruts;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForm;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.Action;
import javax.servlet.http.HttpSession;
import java.math.BigDecimal;
import proejblayer.Business;
import proejblayer.BusinessHome;
import javax.naming.*;
import javax.rmi.PortableRemoteObject;
import org.apache.struts.action.ActionMessages;
public class searchAction extends Action {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) {
searchForm searchForm = (searchForm) form;
HttpSession session = request.getSession();
String accountNo = (String) session.getAttribute("AccountNo");
BigDecimal money = new BigDecimal(0);
money = getmoney(accountNo);
org.apache.struts.util.MessageResources messages = getResources(
request);
ActionMessages errors = new ActionMessages();
request.setAttribute("result", money);
return mapping.findForward("main");
}
public BigDecimal getmoney(String no){
BigDecimal res=new BigDecimal(0);
try{
Context ctx=new InitialContext();
Object obj=ctx.lookup("Business");
BusinessHome home=(BusinessHome)PortableRemoteObject.narrow(obj,
BusinessHome.class);
Business business=home.create();
res=business.searchMoney(no);
}catch(Exception ex){
ex.printStackTrace();
}
return res;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?