python+django MTV框架 和php MVC框架

首先,祝福祖国60华诞,我爱这个国家。 刚才在GR读到Here Comes The Sun的[A shorten url app](http://www.classicning.com/blog/2009/09/a-shorten-url-app/-shorten-url- app/),其中提到了Python下Django框架的一些问题,我很感兴趣,搜索了一下MTV模型,资料很少。但有一篇我读后很有启发,现在转载如下。 原文链接:python+django MTV框架 和php MVC框架的不同之处 - PHP+MYSQL+APACHE - ThinkPHP官方论坛 作者:乔峰 *残酷的分割线 python+django MTV框架 和php MVC框架的不同之处 最近...

2009-10-01 · alswl

Servlet JSP 的 Java类的最简单MVC模型

来自Head First Servlet and JSP XML语言: web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns=“http://java.sun.com/xml/ns/j2ee" xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=“http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version=“2.4”> –> Ch3 Beer com.example.web.BeerSelect Ch3 Beer /SelectBeer.do HTML语言: form.html Beer Selection Page Beer Selection Page select beer characteristics Color: light amber brown dark Java语言: BeerSelect package com.example.web; import com.example.model.*; import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.util.*; public class BeerSelect extends HttpServlet { public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { // response.setContentType(“text/html”); // PrintWriter out = response.getWriter(); // out.println(“Beer Selection Advice ”); String c = request.getParameter(“color”); // out.println(" Got beer color " + c); BeerExpert be = new BeerExpert(); List result = be.getBrands(c); // Iterator it = result.iterator(); // while (it.hasNext()) // { // out.print(" try: " + it.next()); // } request.setAttribute(“styles”, result); RequestDispatcher view = request.getRequestDispatcher(“result.jsp”); view.forward(request, response); } } Java语言: BeerExpert package com.example.model; import java.util.*; public class BeerExpert { public List getBrands (String color) { List brands = new ArrayList(); if (color.equals(“amber”)) { brands.add(“Jack Amber”); brands.add(“Red Moose”); } else { brands.add(“Jail Pale Ale”); brands.add(“Gout Stout”); } return brands; } } Java...

2009-02-18 · alswl