【JavaWeb】Spring入门——HelloWorld
2024-08-24 12:15:37
0.为什么要使用Spring
https://www.cnblogs.com/zmmi/p/7922186.html
1. 下载jar包
https://blog.csdn.net/qq_43540133/article/details/88357857参考此博客
2. 注意建立的是web项目
package com.tutorialspoint; public class HelloWorld {
private String message;
public void setMessage(String message){
this.message = message;
}
public void getMessage(){
System.out.println("Your Message : " + message);
}
}
package com.tutorialspoint;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class MainApp {
public static void main(String[] args) {
ApplicationContext context =
new ClassPathXmlApplicationContext("Beans.xml");
HelloWorld obj = (HelloWorld) context.getBean("helloWorld");
obj.getMessage();
}
}
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> <bean id="helloWorld" class="com.tutorialspoint.HelloWorld">
<property name="message" value="Hello World!"/>
</bean> </beans>
最新文章
- MVC5 Entity Framework学习之Entity Framework高级功能(转)
- Jquery设置Cookie
- 数据库Error:The ScriptCollection in ScriptName not find
- python反转字符串(简单方法)及简单的文件操作示例
- 10个 iOS 用户暂可以嘲笑 Android 的特点
- JedisPool使用原理和源代码
- 解决mac下eclipse字体模糊
- 1198: [HNOI2006]军机调度 - BZOJ
- 转 json数组对象和对象数组
- windows 配置 Scheme + Emacs 编程环境
- Certificate downloaded from cloudexpress:11443 is invalid
- BZOJ 3160: 万径人踪灭 [fft manacher]
- CentOS命令修改系统时间同步
- 桶排序/基数排序(Radix Sort)
- ●Splay的一些题
- 同一脚本sh 脚本名 报Syntax error: ";("; unexpected而./脚本名不报错,求解!!
- 【vue】vue +element 搭建项目,加(解)密
- 使用Python的http.server实现一个简易的Web Api对外提供HanLP拼音转换服务
- Mathematica 11.1.0 下载及注册流程
- 【做题】neerc2017的A、C、I、L