LoginSignup
1
2

More than 5 years have passed since last update.

DTDファイルの属性変更例

Last updated at Posted at 2015-08-21

<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd" [<!ATTLIST bean singleton (true | false) "false">]>

■例:

t1.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
    <beans>
        <bean id="triangleAlone" class="dto.Triangle" >
        </bean>
        <import resource="t1_1.xml" />
    </beans>

t1_1.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd" [<!ATTLIST bean singleton (true|false) "false">]>
    <beans>
        <bean id="triangleParent" class="dto.Triangle">
        </bean>

        <bean id="triangleChild" class="dto.Triangle" parent="triangleParent">
        </bean>
    </beans>

確認
```java

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import dto.Triangle;

public class Test {
    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("dto/t1.xml");

        for (int i = 0; i < 3; i ++) {
            Triangle triangle1 = (Triangle) context.getBean("triangleAlone");
            System.out.println(triangle1);
        }

        for (int i = 0; i < 3; i ++) {
            Triangle triangle1 = (Triangle) context.getBean("triangleParent");
            System.out.println(triangle1);
        }

        for (int i = 0; i < 3; i ++) {
            Triangle triangle2 = (Triangle) context.getBean("triangleChild");
            System.out.println(triangle2);
        }
    }
}
1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2