- 浏览: 82477 次
-
文章分类
- 全部博客 (89)
- web service (9)
- subversion (1)
- JBOSS (3)
- interview (23)
- jQery (2)
- ExtJs (0)
- Axis (0)
- Design pattern (3)
- Agile (2)
- mutithread (0)
- Core Java (24)
- programming methods (1)
- SSH (7)
- jee design (1)
- OO (4)
- books (8)
- other (1)
- JSF (7)
- seam (2)
- Weblogic (4)
- JPA (1)
- ADF (1)
- Spring (5)
- Tomcat (1)
- DWR (2)
- JEE (3)
- Servlet (1)
- EJB (1)
- JDBC (3)
最新评论
-
iloveflower:
呵呵。好好学习。。。。。。。。。。。。
java 读书 -
Eric.Yan:
看了一点,不过是电子版的……你这一说到提醒我了,还要继续学习哈 ...
java 读书
http://sites.google.com/site/sritechforjava/spring-docs/spring-mvc-basics
Assuming that the student knows basic web application structure and all the configuration files required for Basic web application.
Assuming that the student knows Servlets.
To create Annotation based Spring MVC web application please follow the below steps:
Step 1 : Update your web.xml file with following configuration:
<servlet>
<servlet-name>spring-mvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring-mvc</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
DispatcherServlet - Spring's Web MVC framework is designed around a DispatcherServlet that dispatches requests to handlers, with configurable handler mappings, view resolution, locale and theme resolution as well as support for upload files.
A central servlet that dispatches requests to controllers and offers other functionality facilitating the development of web applications.
Is an expression of the “Front Controller” design pattern.
It is completely integrated with the Spring IoC container and as such allows you to use every other feature that Spring has.
The framework will, on initialization of a DispatcherServlet, look for a file named [servlet-name]-servlet.xml in the WEB-INF directory of your web application and create the beans defined there.
Step 2 : Create spring-mvc-servlet.xml under WEB-INF directory. (Observe that the file name should start with servlet-name of the DispatcherServlet-servlet.xml.)
Step 3 : The Basic spring-mvc-servlet.xml looks like below:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
</beans>
Step 4 : spring-mvc-servlet.xml file will contain all of your Spring Web MVC-specific components (beans). The exact location of this configuration file can be changed via a DispatcherServlet initialization parameter. You can specify that in web.xml like below:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:/spring/spring-context.xml</param-value>
</context-param>
Step 5 : Just as with any other view technology you're integrating with Spring, for JSPs you'll need a view resolver that will resolve your views. The most commonly used view resolvers when developing with JSPs are the InternalResourceViewResolver and the ResourceBundleViewResolver.
Add the below configuration in your spring-mvc-servlet.xml file: (I am using InternalResourceViewResolver here in this example)
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".jsp"/>
</bean>
Step 6 : Here as we are going to use annotations instead of configuring our Controllers in xml files, we also need to add the following configuration in spring-mvc-servlet.xml file, so that container scans all the controller components at the initialization of DispatcherServlet and they will be available.
<context:component-scan base-package="com.sritech.samples">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
Step 7 : Your web application lib directory also need the following spring jars:
spring.jar
spring-webmvc.jar
commons-logging.jar
These jars will be deployed to the server and they are also used during the build process.
The above configuration allows your DispatcherServlet to scan for all the controllers in the specified package (Ex: com.sritech.samples).
All above 6 Steps are one time configuration you have to do to create your annotation based Spring MVC application.
Example 1:- Create Welcome Page using SimpleWelcomeController and Simple JSP.
Step 1 : Create the controller class:
package com.sritech.samples.mvc.example1;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class SimpleWelcomeController {
@RequestMapping("/example1/welcome.htm")
public void elementaryGreeter() {
}
}
The @Controller annotation indicates that a particular class serves the role of a controller. There is no need to extend any controller base class or reference the Servlet API. You are of course still able to reference Servlet-specific features if you need to. The basic purpose of the @Controller annotation is to act as a stereotype for the annotated class, indicating its role. The dispatcher will scan such annotated classes for mapped methods, detecting @RequestMapping annotations.
The @RequestMapping annotation is used to map URLs like '/example1/welcome.htm' onto an entire class or a particular handler method.
Step 2 : Create the JSP.
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Welcome to Spring MVC</title>
</head>
<body>
Hello everyone! Welcome to Spring MVC: Example 1
</body>
</html>
Step 3 : Now create the war file and deploy into your Tomcat Server. (Any Web Server or application Server).
Step 4 : After the application is deployed go the below link:
http://server-name:portNumber/spring-mvc-samples/example1/welcome.htm
Step 5 : You will be seeing the following output on your screen:
Welcome to Spring MVCHello everyone! Welcome to Spring MVC: Example 1
Surprised!
Continue...
Assuming that the student knows basic web application structure and all the configuration files required for Basic web application.
Assuming that the student knows Servlets.
To create Annotation based Spring MVC web application please follow the below steps:
Step 1 : Update your web.xml file with following configuration:
<servlet>
<servlet-name>spring-mvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring-mvc</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
DispatcherServlet - Spring's Web MVC framework is designed around a DispatcherServlet that dispatches requests to handlers, with configurable handler mappings, view resolution, locale and theme resolution as well as support for upload files.
A central servlet that dispatches requests to controllers and offers other functionality facilitating the development of web applications.
Is an expression of the “Front Controller” design pattern.
It is completely integrated with the Spring IoC container and as such allows you to use every other feature that Spring has.
The framework will, on initialization of a DispatcherServlet, look for a file named [servlet-name]-servlet.xml in the WEB-INF directory of your web application and create the beans defined there.
Step 2 : Create spring-mvc-servlet.xml under WEB-INF directory. (Observe that the file name should start with servlet-name of the DispatcherServlet-servlet.xml.)
Step 3 : The Basic spring-mvc-servlet.xml looks like below:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
</beans>
Step 4 : spring-mvc-servlet.xml file will contain all of your Spring Web MVC-specific components (beans). The exact location of this configuration file can be changed via a DispatcherServlet initialization parameter. You can specify that in web.xml like below:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:/spring/spring-context.xml</param-value>
</context-param>
Step 5 : Just as with any other view technology you're integrating with Spring, for JSPs you'll need a view resolver that will resolve your views. The most commonly used view resolvers when developing with JSPs are the InternalResourceViewResolver and the ResourceBundleViewResolver.
Add the below configuration in your spring-mvc-servlet.xml file: (I am using InternalResourceViewResolver here in this example)
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".jsp"/>
</bean>
Step 6 : Here as we are going to use annotations instead of configuring our Controllers in xml files, we also need to add the following configuration in spring-mvc-servlet.xml file, so that container scans all the controller components at the initialization of DispatcherServlet and they will be available.
<context:component-scan base-package="com.sritech.samples">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
Step 7 : Your web application lib directory also need the following spring jars:
spring.jar
spring-webmvc.jar
commons-logging.jar
These jars will be deployed to the server and they are also used during the build process.
The above configuration allows your DispatcherServlet to scan for all the controllers in the specified package (Ex: com.sritech.samples).
All above 6 Steps are one time configuration you have to do to create your annotation based Spring MVC application.
Example 1:- Create Welcome Page using SimpleWelcomeController and Simple JSP.
Step 1 : Create the controller class:
package com.sritech.samples.mvc.example1;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class SimpleWelcomeController {
@RequestMapping("/example1/welcome.htm")
public void elementaryGreeter() {
}
}
The @Controller annotation indicates that a particular class serves the role of a controller. There is no need to extend any controller base class or reference the Servlet API. You are of course still able to reference Servlet-specific features if you need to. The basic purpose of the @Controller annotation is to act as a stereotype for the annotated class, indicating its role. The dispatcher will scan such annotated classes for mapped methods, detecting @RequestMapping annotations.
The @RequestMapping annotation is used to map URLs like '/example1/welcome.htm' onto an entire class or a particular handler method.
Step 2 : Create the JSP.
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Welcome to Spring MVC</title>
</head>
<body>
Hello everyone! Welcome to Spring MVC: Example 1
</body>
</html>
Step 3 : Now create the war file and deploy into your Tomcat Server. (Any Web Server or application Server).
Step 4 : After the application is deployed go the below link:
http://server-name:portNumber/spring-mvc-samples/example1/welcome.htm
Step 5 : You will be seeing the following output on your screen:
Welcome to Spring MVCHello everyone! Welcome to Spring MVC: Example 1
Surprised!
Continue...
发表评论
-
SpringMVC, JQuery, JSON
2012-06-07 21:33 1483http://viralpatel.net/blogs/201 ... -
step by step guide to DWR 3.RC1 and Sprig 3.0.2 Integration
2012-05-25 04:16 1530step by step guide to DWR 3.RC1 ... -
dwr step by step
2012-05-25 03:50 828http://blog.csdn.net/bruesz/art ... -
DWR+SpringMVC integration
2012-05-17 22:04 1199http://directwebremoting.org/dw ... -
Spring MVC Tutorial
2012-05-16 03:57 2378http://www.mkyong.com/tutorials ... -
关键字:Hibernate注释大全收藏
2012-05-16 03:50 669关键字:Hibernate注释大全收藏 声明实体Bean ... -
struts1.x、hibernate和spring2.x集成方式
2012-05-15 23:17 706come from: http://blog.csdn.net ... -
Spring3.x 之ScrollableSupportJdbcTemplate
2012-05-15 01:29 1045public class ScrollableSupportJ ... -
Spring的JTA管理
2012-03-18 21:29 729http://www.iteye.com/topic/1114 ... -
Struts+Spring+Hibernate(JPA) + Ajax整合详解
2012-03-15 23:30 864Struts+Spring+Hibernate(JPA) + ...
相关推荐
- **域类Web绑定(Domain Class Web Binding)**:利用Spring MVC将域对象绑定到Web请求。 - **Web分页(Web Pagination)**:提供在Web应用中实现分页显示的支持。 - **仓库填充器(Repository Populators)**:...
3. New Features and Enhancements in Spring Framework 4.0 ............................................ 17 3.1. Improved Getting Started Experience .........................................................
3. New Features and Enhancements in Spring Framework 4.0 ............................................ 17 3.1. Improved Getting Started Experience .........................................................
内容概要:本文详细介绍了基于TMS320F系列芯片的C2000串口读写方案及其编程器——FlashPro2000的功能特点和支持的接口模式。文中不仅涵盖了硬件连接的具体步骤,还提供了代码实例来展示Flash擦除操作,并对比了JTAG和SCI-BOOT两种模式的优缺点。此外,针对不同型号的C2000系列芯片,给出了详细的适配指导以及避免烧录过程中可能出现的问题的方法。 适合人群:从事DSP开发的技术人员,尤其是对TI公司C2000系列芯片有一定了解并希望深入了解其编程和烧录细节的人群。 使用场景及目标:适用于实验室环境下的程序调试阶段,以及生产线上的批量烧录任务。主要目的是帮助开发者选择合适的编程工具和技术手段,提高工作效率,减少因误操作导致设备损坏的风险。 其他说明:文中提供的代码片段和命令行指令可以直接用于实际项目中,同时附带了一些实用技巧,如防止芯片变砖的小贴士和自动化重试脚本,有助于解决常见的烧录难题。
汉字字库存储芯片扩展实验 # 汉字字库存储芯片扩展实验 ## 实验目的 1. 了解汉字字库的存储原理和结构 2. 掌握存储芯片扩展技术 3. 学习如何通过硬件扩展实现大容量汉字字库存储 ## 实验原理 ### 汉字字库存储基础 - 汉字通常采用点阵方式存储(如16×16、24×24、32×32点阵) - 每个汉字需要占用32字节(16×16)到128字节(32×32)不等的存储空间 - 国标GB2312-80包含6763个汉字,需要较大存储容量 ### 存储芯片扩展方法 1. **位扩展**:增加数据总线宽度 2. **字扩展**:增加存储单元数量 3. **混合扩展**:同时进行位扩展和字扩展 ## 实验设备 - 单片机开发板(如STC89C52) - 存储芯片(如27C256、29C040等) - 逻辑门电路芯片(如74HC138、74HC373等) - 示波器、万用表等测试设备 - 连接线若干 ## 实验步骤 ### 1. 单芯片汉字存储实验 1. 连接27C256 EPROM芯片到单片机系统 2. 将16×16点阵汉字字库写入芯片 3. 编写程序读取并显示汉字 ### 2. 存储芯片字扩展实验 1. 使用地址译码器(如74HC138)扩展多片27C256 2. 将完整GB2312字库分布到各芯片中 3. 编写程序实现跨芯片汉字读取 ### 3. 存储芯片位扩展实验 1. 连接两片27C256实现16位数据总线扩展 2. 优化字库存储结构,提高读取速度 3. 测试并比较扩展前后的性能差异 ## 实验代码示例(单片机部分) ```c #include <reg52.h> #include <intrins.h> // 定义存储芯片控制引脚 sbit CE = P2^7; // 片选 sbit OE = P2^6; // 输出使能 sbit
测控装备干扰源快速侦测系统设计研究.pdf
嵌入式八股文面试题库资料知识宝典-【开发】嵌入式开源项目&库&资料.zip
嵌入式八股文面试题库资料知识宝典-百度2022年嵌入式面试题.zip
少儿编程scratch项目源代码文件案例素材-空间站.zip
基于关联规则的商业银行个性化产品推荐.pdf
嵌入式八股文面试题库资料知识宝典-Linux基础使用.zip
内容概要:本文详细介绍了利用MATLAB进行轴棱锥生成贝塞尔高斯光束及环形光束光强图像的仿真研究。首先阐述了实验的背景与目标,强调了MATLAB在光学和计算科学领域的广泛应用。接着,具体描述了实验的方法与步骤,包括材料准备、仿真过程中的参数设定和光束生成代码编写。最后,对实验结果进行了深入分析,展示了贝塞尔高斯光束和环形光束的光强分布特点,验证了其光学性能的预期表现。文章还对未来的研究方向和技术改进提出了展望。 适合人群:从事光学、物理学及相关领域研究的专业人士,特别是对光束生成和光学性能分析感兴趣的科研工作者。 使用场景及目标:适用于需要进行光束生成和性能分析的实验室环境,旨在帮助研究人员更好地理解和优化光束特性和传播行为。 其他说明:本文不仅提供了详细的实验方法和步骤,还附有丰富的实验结果和数据分析,为后续研究提供了宝贵的参考资料。
内容概要:本文探讨了三电平NPC型有源电力滤波器(APF)的模型预测控制(MPC)中存在的开关频率过高问题及其解决方案。传统MPC方法会导致极高的开关频率,增加了系统的能耗和热量。通过引入滞环控制模块,可以在不大幅牺牲性能的情况下有效降低开关频率。具体来说,滞环控制通过在价值函数计算后增加一个判断条件,对状态切换进行惩罚,从而减少不必要的开关动作。实验结果显示,开关频率从4392Hz降至3242Hz,降幅达26.2%,虽然电流总谐波畸变率(THD)略有上升,但仍符合国家标准。此外,文中还提出了动态调整滞环宽度的方法,以进一步优化不同负载条件下的表现。 适合人群:从事电力电子、电力系统控制领域的研究人员和技术人员,特别是关注APF和MPC技术的人群。 使用场景及目标:适用于需要优化APF系统开关频率的研究和工程项目,旨在提高系统效率并降低成本。目标是在不影响系统性能的前提下,显著降低开关频率,减少能量损失和热管理难度。 其他说明:文章不仅提供了理论分析,还包括具体的实现代码片段,有助于读者理解和实践。同时,强调了在实际应用中需要注意的问题,如中点电位漂移等。
内容概要:本文介绍了三维POD DMD程序在处理原网格数据方面的独特优势和技术细节。首先阐述了该程序能读取结构化和非结构化网格数据及其拓扑关系,在生成模态数据过程中保持原始网格形态而不需要进行网格插值操作。接着展示了简化版本的Python代码片段,揭示了读取网格数据和生成模态数据的核心逻辑。最后提到提供的辅助学习资料如代码、视频教程、Word教程和实例数据,帮助用户深入理解并掌握该程序的应用。 适合人群:从事计算流体力学领域的研究人员和技术爱好者,尤其是那些希望提高数据处理效率的人群。 使用场景及目标:适用于需要处理复杂网格数据的研究项目,旨在简化数据处理流程,提升工作效率,同时保持数据的原始特性。 其他说明:文中不仅提供了理论性的讲解,还有具体的代码示例和丰富的学习资源,使读者可以边学边练,快速上手。
融合双向路由注意力的多尺度X光违禁品检测.pdf
嵌入式八股文面试题库资料知识宝典-Linux_Shell基础使用.zip
嵌入式八股文面试题库资料知识宝典-联发科2021武汉嵌入式软件开发.zip
基于有限体积法Godunov格式的管道泄漏检测模型研究.pdf
嵌入式八股文面试题库资料知识宝典-ARM常见面试题目.zip