关于spring的p标签

来源:互联网 发布:linux系统驱动开发 编辑:程序博客网 时间:2024/06/06 01:40

spring p标签是spring内置的,只要在xml头部申明下就可以调用,用法相当于<property>

比如

<?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:p="http://www.springframework.org/schema/p" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> 
<bean id="loginAction" class="com.ambow.exam.action.LoginAction" p:nam="sasa"></bean> 
</beans>

 

这里是给LoginAction里给nam注入值sasa

这里相当于

 

<?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:p="http://www.springframework.org/schema/p" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> 
<bean id="loginAction" class="com.ambow.exam.action.LoginAction"> 
<property name="nam"> 
<value>sasa</value> 
</property> 
</bean> 
</beans>

原创粉丝点击