那样实现起来很麻烦,怎么实现 View 和Model的通讯,怎样转换调度,很负责哦struts 很好啊,为什么不用这样成熟的框架呢,全世界都在用他~

解决方案 »

  1.   

    我现在就是不知道 该怎么把bean的处理结果返回给jsp阿
    不像struts有配置文件
    struts里很多细节都封装起来了,先弄懂原始的mvc模式,以后很多问题就容易解决了
      

  2.   

    ^_^ . 直接看 Struts 源码不就行. 看关于 Struts 的工作过程的一个时序图就知道了.Bean 返回的结果代表一个页面就行了,比如直接返回  /user/startpage.jsp, 把必要的变量放到requestScope 中 ,然后让 Servlet forward 到那个页面去,那个页再去 requestScope 中取.Strus 用一个 配置文件中的 forward 名字代表那个页面了,在请求进来的时候 Servlet 用 xxx.do 找到 ActionMapping  并 把所有的 参数都填到  ActionMapping 对应的 formBean 中,然后用这个 formBean 和 actionMapping 及 request 去调用那个 ActionBean , actionBean 把下一个要去的页面的名字返回给 ActionServlet . ActionServlet 就到那个 actionMapping 中 找到 对应的页面 forward 过去.
      

  3.   

    我现在的理解是这样的:servlet里面调用javabean进行逻辑处理,生成一个存储结果的bean,再把这个bean放在request对象里.根据情况用RequestDispatcher分发给不同的jsp页面.再在jsp里面usebean?
    总感觉有点怪怪的,不知道设么样才算好的mvc
      

  4.   

    V:JSP
    C:Servlet
    M:Jdbc/Hibernate/...完全可以自己控制,根本用不着Struts的,当然用也8错
      

  5.   

    public class BbsAction extends HttpServlet {
    private BbsManager bbsManager=new com.test.frame.service.BbsManagerImpl();

    public void service(HttpServletRequest req, HttpServletResponse res) {
    String method = req.getParameter("method");
    if (!method.equals(""))
    try {
    Class[] param = new Class[] { HttpServletRequest.class,
    HttpServletResponse.class };
    Object paramValues1[] = new Object[] { req, res };
    Method meth = getClass().getDeclaredMethod(method, param);
    meth.invoke(this, paramValues1);
    } catch (Exception e) {
    System.out.println("reflect failure:" + method + ":"
    + e.toString());
    }
    } /**
     * 查询请求操作
     * 
     * @param req
     * @param res
     * @throws Exception
     */
    public void searchRequestAction(HttpServletRequest req,
    HttpServletResponse res){
    try {
    HttpSession mySession = req.getSession();
    mySession.setAttribute(Constants.SQL_WHERE, null);
    mySession.setAttribute(Constants.SQL_ORDER, null);
    this.getServletContext().getRequestDispatcher(
    "/servlet/bbs_search.jsp").forward(req, res);
    } catch (Exception e) {
    Normal.listLog("Action:searchRequestAction:" + e.toString(),
    BooleanUtil.parse(MessageResources.get("index.isTestLog")));
    }
    }
    .
    .
    .
    ..
    .
    }
      

  6.   

    public class BbsAction extends DispatchAction {
    private BbsManager bbsManager= new BbsManagerImpl();
    /**
     * 查询请求操作
     * 
     * @param mapping
     * @param form
     * @param req
     * @param res
     * @return ActionForward
     * @throws Exception
     */
    public ActionForward searchRequestAction(ActionMapping mapping,
    ActionForm form, HttpServletRequest req, HttpServletResponse res)
    throws Exception {
    try {
    req.removeAttribute(mapping.getAttribute());
    HttpSession mySession = req.getSession();
    mySession.setAttribute(Constants.SQL_WHERE, null);
    mySession.setAttribute(Constants.SQL_ORDER, null);
    return (mapping.findForward("success"));
    } catch (Exception e) {
    Normal.listLog("Action:searchRequestAction:" + e.toString(),
    BooleanUtil.parse(MessageResources.get("index.isTestLog")));
    throw e;
    }
    }这里的struts与上面的servlet实现的功能一模一样,代码也几乎相同.
    M:可以是一般的jdbc,也可以是hibernate等等
      

  7.   

    最近在边学便用WEBWORK 效果非常好