pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test</groupId>
<artifactId>spring</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>spring Maven Webapp</name>
<url>http://maven.apache.org</url>
<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0</url>
</license>
</licenses>
<developers>
<developer>
<id>zzzz</id>
<name>caicai</name>
<email>806846483@qq.com</email>
<organization>ShuWang Software, Inc.</organization>
<organizationUrl>www.shuwang.info</organizationUrl>
<roles>
<role>
Project Lead
</role>
</roles>
</developer>
</developers>
<properties>
<spring.version>4.2.3.RELEASE</spring.version>
</properties> <dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>
<!--
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>${spring.version}</version>
</dependency>
-->
</dependencies>
<build>
<finalName>spring</finalName>
<sourceDirectory>src/main/java</sourceDirectory>
<outputDirectory>target/classes</outputDirectory>
<resources>
<resource>
<filtering>true</filtering>
<directory>
src/main/resources
</directory>
<includes>
<include>**/application.properties</include>
<include>**/application.yml</include>
</includes>
</resource>
</resources>
</build>
</project>

  web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>spring</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF/application.xml</param-value>
</context-param>
<listener>
<description>springWebContextLoaderListener</description>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
</web-app>

  application.xml

<?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">
<context:component-scan base-package="com.jiangchong.test"/>
</beans>

  测试用的jsp

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@page import="org.springframework.web.context.WebApplicationContext"%>
<html>
<body>
<h2>Hello World!</h2>
<h3>
<%
WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(this.getServletContext());
String get = (String)wac.getBean("get");
out.println(get);
%>
</h3>
</body>
</html>

  TestTest.class

package com.jiangchong.test;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; @Configuration
public class TestTest implements InitializingBean
{
@Autowired
String get; public void afterPropertiesSet() throws Exception
{
System.out.println(get);
} @Bean
public TestTest list()
{
return new TestTest();
}
}

  Test.class

package com.jiangchong.test;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; @Configuration
public class Test
{
@Bean
public String get()
{
return new String("test");
} }

  至此把Web容器和Spring关联起来了,看不懂面墙去

裸奔Spring(1)的更多相关文章

  1. 裸奔的智能插座:博联Broadlink SP2/SP mini的分析、破解

    https://www.jianshu.com/p/028b10bc3dd1 智能设备的联动通常采用IFTTT的方式,但这种方式受限于官方软件提供的功能.想要自主地灵活控制,需要有官方SDK,或知道协 ...

  2. 记一次MongoDB裸奔

    导言 大意失荆州,裸奔的 MongoDB 被黑了.虽然并不是什么非常重要的数据,但也给自己敲响的一个警钟.虽然我们平时不容易接触到数据安全,但我们在开发,部署项目的时候,一定要养成良好的安全意识. 根 ...

  3. S3C6410裸奔之旅——RVDS2.2编译、仿真、调试过程 LED流水灯---转的

    S3C6410裸奔之旅——RVDS2.2编译.仿真.调试过程 LED流水灯 (2012-10-13 23:56:30) 转载▼ 标签: s3c6410裸奔 ok6410 rvds2.2 rvds2.2 ...

  4. (转)裸奔的后果!一次ssh被篡改的入侵事件

    裸奔的后果!一次ssh被篡改的入侵事件 原文:http://blog.51cto.com/phenixikki/1546669 通常服务器安全问题在规模较小的公司常常被忽略,没有负责安全的专员,尤其是 ...

  5. 裸奔着造房子——对政府禁止采购Win8系统的一些看法

    前段时间有消息称政府招标的项目将禁止使用Win8系统,原因是Win8系统的安全架构将有利于暴露敏感信息给微软,而微软的老子是美利坚,老子想要知道什么,儿子当然不敢不从.因此Win8也被打入冷宫,微软多 ...

  6. 裸奔的支付X聊天,你还敢用吗?

    - 语音消息 使用HTTP明文传输,没有任何加密措施,使用域名为up-mayi.django.t.taobao.com,从报文中可以看出,语音消息是以文件形式在网络中传输的,下图为一次语音的发送传输过 ...

  7. PJzhang:如何在裸奔的年代找到一些遮羞布

    猫宁!!! 很久以前的一篇,搬过来. 我一直在“裸奔”,而且很久了,只是不太愿意承认. 想起了“皇帝的新装”,好奇何种经历和灵感让安徒生写出了如此精彩的故事. 一次百度了一个商品,不久接到了大规模电话 ...

  8. 跟我一起学.NetCore之WebApi接口裸奔有风险(Jwt)

    前言 撸码需谨慎,裸奔有风险.经常在一些技术交流群中了解到,还有很多小伙伴的项目中Api接口没有做任何安全机制验证,直接就裸奔了,对于一些临时项目或是个人小项目还好,其余的话,建议小伙伴们酌情考虑都加 ...

  9. 网骗欺诈?网络裸奔?都是因为 HTTP?

    先跟大家讲个故事,我初恋是在初中时谈的,我的后桌的后桌.那个时候没有手机这类的沟通工具,上课交流有三宝,脚踢屁股.笔戳后背以及传纸条,当然我只能是那个屁股和后背,还不是能让初恋踢到的后背. 但是说实话 ...

随机推荐

  1. Substring with Concatenation of All Words

    You are given a string, s, and a list of words, words, that are all of the same length. Find all sta ...

  2. About SQLite

    About SQLite See Also... Features When to use SQLite Frequently Asked Questions Well-known Users Boo ...

  3. Angular2学习之开发环境构建

    一.主要资料 http://blog.csdn.net/cz_jjq/article/details/50425206 http://www.tuicool.com/articles/mi6rmuB ...

  4. javascript中bind函数的作用

    javascript的bind的作用 <!DOCTYPE html> <html> <head> <meta charset="utf-8" ...

  5. ALV 顶栏的按钮设定

    *&---------------------------------------------------------------------* *& Report ZHJ_TEST0 ...

  6. 路由 - ASP.NET MVC 4 系列

           软件开发人员常常对一些细小的细节问题倍加关注,由其在考虑源代码的质量和结构时更是如此.因此,当遇到大部分使用 ASP.NET 技术构建的站点,使用如下的 URL 地址时,可能会有些奇怪: ...

  7. js获取ip地址

    方法三(所有的平台及浏览器):使用的搜狐接口 <script src="http://pv.sohu.com/cityjson?ie=utf-8"></scrip ...

  8. photoshop, 钢笔上色

    photoshop中用 钢笔工具 勾好轮廓后,使用 路径选择工具 选中轮廓,右键弹出菜单中选 创建矢量蒙板,然后就可以在区域内用 笔刷工具 涂抹上色,不用担心出界了. ----补充2017-1-2 将 ...

  9. WebLogic Server官方下载地址

    WebLogic Server官方下载地址 英文(更新到12c和9.2.4):http://www.oracle.com/technetwork/middleware/ias/downloads/wl ...

  10. android学习笔记57——电话管理器TelephoneyManager

    电话管理器TelephoneyManager