`
文章列表

语句记录

一:基于 ORM 的框架需要一个事务来触发对象缓存与数据库之间的同步。 让基本的 @Transactional 注释在 清单 4 的代码中工作仅仅是开始。注意,清单 4 使用 @Transactional 注释时没有指定任何额外的注释参数。我发现许多开发人员在使用 @Transactional 注释时并没有花时间理解它的作用。例如,像我一样在清单 4 中单独使用 @Transactional 注释时,事务传播模式被设置成什么呢?只读标志被设置成什么呢?事务隔离级别的设置是怎样的?更重要的是,事务应何时回滚工作?理解如何使用这个注释对于确保在应用程序中获得合适的事务支持级别非常重要。回答我刚才提 ...

多线程的困惑

多线程的困惑 转自:http://www.ibm.com/developerworks/cn/java/j-lo-spring-ts1/index.html 由于 Spring 的事务管理器是通过线程相关的 ThreadLocal 来保存数据访问基础设施,再结合 IOC 和 AOP 实现高级声明式事务的功能,所以 Spring 的事务天然地和线程有着千丝万缕的联系。 我们知道 Web 容器本身就是多线程的,Web 容器为一个 Http 请求创建一个独立的线程,所以由此请求所牵涉到的 Spring 容器中的 Bean 也是运行于多线程的环境下。在绝大多数情况下,Spring 的 Bean 都 ...

pom.xml

tomcat-users.xml <?xml version='1.0' encoding='utf-8'?> <tomcat-users> <role rolename="manager"/> <user username="test" password="test" roles="manager"/> </tomcat-users> settings.xml server entry <server> < ...

Spring 记录

Actually, the ‘ref’ tag can access to a bean either in same or different XML files, however, for the project readability, you should use the ‘local’ attribute if you reference to a bean which declared in the same XML file.
1. 首先编写pom.xml文件,加入Spring MVC依赖的jar包。 2. 编辑web.xml,加入Spring MVC的前端控制器。代码如下: <servlet> <servlet-name>bbs</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> < ...

Spring modules

The Spring Framework is composed of several distinct modules. When you download and unzip the Spring Framework distribution, you’ll find 20 different JAR files in the dist directory, as shown in figure 1.6. The 20 JAR files that make up Spring can be arranged in one of six different cate-gories of ...

a bean`s life

a bean`s life 1 Spring instantiates the bean. 2 Spring injects values and bean references into the bean’s properties. 3 If the bean implements BeanNameAware, Spring passes the bean’s ID to the set-BeanName() method. 4 If the bean implements BeanFactoryAware, Spring calls the setBeanFactory() meth ...
以下为自我记录,翻译玩的,如出现错误请参考英文O(∩_∩)O~ following a request through Spring MVC As we can see in the picture, When the request leaves the browser, it carries information what user is asking for. At least, the request will be carrying the requested URL. But it may carry additional data such as the informat ...
HTML generated by JSP template @RequestMapping(value="/html", method=RequestMethod.GET) public ModelAndView prepare() { System.out.println("aaa"); ModelAndView mav = new ModelAndView("test_mvc"); mav.addObject("foo", "bar"); mav.addObject( ...
Read a String Read string 'foo' @RequestMapping(value="/string", method=RequestMethod.POST) public @ResponseBody String readString(@RequestBody String string) { return "Read string '" + string + "'"; } Write a String Wrote a string @RequestMapping(value="/strin ...
Response Body http://localhost:8080/spring_mvc_test/response/annotation @RequestMapping(value="/response/annotation", method=RequestMethod.GET) public @ResponseBody String responseBody() { String message = "The String ResponseBody"; return message; } ResponseEntity(custom ...
Obtained 'foo' query parameter value 'bar' http://localhost:8080/spring_mvc_test/data/param?foo=test @RequestMapping(value="param") public @ResponseBody String withParam(@RequestParam String foo) { String message = "Obtained 'foo' query parameter value '" + foo + "'& ...
http://localhost:8080/spring_mvc_test/simple @RequestMapping("simple") public @ResponseBody String helloWorld() { String message = "Hello, this is a simple example"; System.out.println(message); return message; } mapping by path http://localhost:8080/spring_mvc ...
1. 建立项目spring_mvc_test 2. 引入jar文件,如图: 3. 下面编辑web.xml文件,配置spring的拦截器: <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi: ...

HelloWorld

Maven的安装 1.下载Maven然后解压到D:\software。当然别的文件夹也可以 2.设置环境变量 M2_HOME:D:\software\apache-maven-2.0.11 M2:%M2_HOME%\bin 3.在命令行输入mvn -version查看安装结果 HelloWorld程序 1.首先建立一个项目根目录:D:\maven_test\helloworld 2.在根目录下编写pom.xml文件: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi=& ...
Global site tag (gtag.js) - Google Analytics