RSS
热门关键字:
当前位置 : 主页>编程开发>java编程>J2EE>列表

Spring MVC 开发快速入门

来源:我要研发网 作者:Blog ideawu 时间:2008-03-02 点击:



1 2 下一页 字串9

  这篇文章将教你快速地上手使用 Spring 框架,如果你手上有一本《Spring in Action》, 那么你最好从第三部分\"Spring 在 字串6

  首先, 我需要在你心里建立起 Spring MVC 的基本概念. 基于 Spring 的 Web 应用程序接收到 http://localhost:8080/hello.do(事实上请求路径是 /hello.do) 的请求后, Spring 将这个请求交给一个名为 helloController 的程序进行处理, helloController 再调用 一个名为 hello.JSP 的 jsp 文件生成 HTML 代码发给用户的浏览器显示. 上面的名称(/hello.do, helloController, hello.jsp) 都是变量, 你可以更改.

字串1

  在 Spring MVC 中, jsp 文件中尽量不要有 Java 代码, 只有 HTML 代码和\"迭代(forEach)\"与\"判断(if)\"两个jstl标签. jsp 文件只作为渲染(或称为视图 View)模板使用.

字串6

  好了, 我们开始吧. 首先我们需要一个放在 WEB-INF 目录下的 web.XML 文件:

字串4

web.xml:
 1 <?xml version=\"1.0\" encoding=\"UTF-8\"?>
2
3 web-app version=\"2.4\" xmlns=\"http://java.sun.com/xml/ns/j2ee\"
4 xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
5 xsi:schemaLocation=\"http://java.sun.com/xml/ns/j2ee
字串5

6 http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd\"
7
8 context-param
9 param-namecontextConfigLocation</param-name>
10 param-value
11 /WEB-INF/database.xml
12 /WEB-INF/applicationContext.xml
13 </param-value>
14 </context-param>
15
16 listener 字串7
17 listener-classorg.springFramework.web.context.ContextLoaderListener</listener-class>
18 </listener>
19
20 filter
21 filter-nameencodingFilter</filter-name>
22 filter-classorg.springframework.web.filter.CharacterEncodingFilter</filter-class>
23 init-param 字串2
24 param-nameencoding</param-name>
25 param-valueUTF-8</param-value>
26 </init-param>
27 </filter>
28
29 filter-mapping
30 filter-name
最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名?
注册