


Detailed explanation of examples of passing values in JSP Spring configuration files
This article mainly introduces JSP SpringConfiguration fileRelated JSP information with detailed examples of passed values. Friends who are interested in JSP can refer to this article.
Detailed explanation of examples of passing values in JSP Spring configuration files
Use spring to provide methods to get passed values in configuration files
Call the get method
TargetObject: Specify the object to be called
PropertyPath: Specify which getter method to call
Example 1:
public class Test1 { private String name = "nihao"; public String getName() { return name; } }
Xml code:
<bean id="t1" class="i.test.Test1" /> <!-- name = t1.getName() --> <bean id="name" class="org.springframework.beans.factory.config.PropertyPathFactoryBean" p:targetObject-ref="t1" p:propertyPath="name" />
Example 2:
Java code
public class Test3 { private Test1 t1 = new Test1(); private String name; public void setName(String name) { this.name = name; } public Test1 getT1() { return t1; } }
Xml code:
<!-- 将t1的name属性值赋给t3的name --> <bean id="t3" class="i.test.Test3"> <property name="name"> <!-- 执行t3.getT1().getName() --> <bean id="t3.t1.name" class="org.springframework.beans.factory.config.PropertyPathFactoryBean" /> </property> </bean>
Access the Filed property of the class
Java code:
public class Test3 { public String name = "nihao"; public static final int MAX_LENGTH = 10; }
Xml code:
<bean id="t3" class="i.test.Test3" /> <!-- 访问成员Field 需要实例 --> <bean id="name" class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean" p:targetObject-ref="t3" p:targetField="name" />
Xml Code:
<!-- 访问静态field只需要类路径 --> <bean id="length" class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean" p:targetClass="i.test.Test3" p:targetField="MAX_LENGTH" /> <!-- 或者 --> <bean id="length" class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean" p:staticField="i.test.Test3.MAX_LENGTH" />
Calling class method
Java code:
public class Test3 { public void execute(String str, int i) { System.err.println(str + "--" + i); } }
Xml code:
<bean id="t3" class="i.test.Test3" /> <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean" p:targetObject-ref="t3" p:targetMethod="execute"> <property name="arguments"> <list> <value>nihao</value> <value>56</value> </list> </property> </bean>
The above is an article about examples of value transfer in JSP Spring configuration files. There are many articles about JSP Spring development on this site. I hope it will be helpful to everyone's learning! !
Related recommendations:
jsPlumb flow chart experience summary
Declaration and usage instructions of variables and methods in jsp
JSP export Excel table example detailed explanation
The above is the detailed content of Detailed explanation of examples of passing values in JSP Spring configuration files. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



In 2023, AI technology has become a hot topic and has a huge impact on various industries, especially in the programming field. People are increasingly aware of the importance of AI technology, and the Spring community is no exception. With the continuous advancement of GenAI (General Artificial Intelligence) technology, it has become crucial and urgent to simplify the creation of applications with AI functions. Against this background, "SpringAI" emerged, aiming to simplify the process of developing AI functional applications, making it simple and intuitive and avoiding unnecessary complexity. Through "SpringAI", developers can more easily build applications with AI functions, making them easier to use and operate.

As an industry leader, Spring+AI provides leading solutions for various industries through its powerful, flexible API and advanced functions. In this topic, we will delve into the application examples of Spring+AI in various fields. Each case will show how Spring+AI meets specific needs, achieves goals, and extends these LESSONSLEARNED to a wider range of applications. I hope this topic can inspire you to understand and utilize the infinite possibilities of Spring+AI more deeply. The Spring framework has a history of more than 20 years in the field of software development, and it has been 10 years since the Spring Boot 1.0 version was released. Now, no one can dispute that Spring

How to implement spring programmatic transactions: 1. Use TransactionTemplate; 2. Use TransactionCallback and TransactionCallbackWithoutResult; 3. Use Transactional annotations; 4. Use TransactionTemplate in combination with @Transactional; 5. Customize the transaction manager.

Recently, many Win10 system users want to change the user profile, but they don’t know how to do it. This article will show you how to set the user profile in Win10 system! How to set up user profile in Win10 1. First, press the "Win+I" keys to open the settings interface, and click to enter the "System" settings. 2. Then, in the opened interface, click "About" on the left, then find and click "Advanced System Settings". 3. Then, in the pop-up window, switch to the "" option bar and click "User Configuration" below.

How to set the transaction isolation level in Spring: 1. Use the @Transactional annotation; 2. Set it in the Spring configuration file; 3. Use PlatformTransactionManager; 4. Set it in the Java configuration class. Detailed introduction: 1. Use the @Transactional annotation, add the @Transactional annotation to the class or method that requires transaction management, and set the isolation level in the attribute; 2. In the Spring configuration file, etc.

JavaScript tutorial: How to get HTTP status code, specific code examples are required. Preface: In web development, data interaction with the server is often involved. When communicating with the server, we often need to obtain the returned HTTP status code to determine whether the operation is successful, and perform corresponding processing based on different status codes. This article will teach you how to use JavaScript to obtain HTTP status codes and provide some practical code examples. Using XMLHttpRequest

Helm is an important component of Kubernetes that simplifies the deployment of Kubernetes applications by bundling configuration files into a package called HelmChart. This approach makes updating a single configuration file more convenient than modifying multiple files. With Helm, users can easily deploy Kubernetes applications, simplifying the entire deployment process and improving efficiency. In this guide, I'll cover different ways to implement Helm on Ubuntu. Please note: The commands in the following guide apply to Ubuntu 22.04 as well as all Ubuntu versions and Debian-based distributions. These commands are tested and should work correctly on your system. in U

An effective method to solve the garbled problem of eclipse requires specific code examples. In recent years, with the rapid development of software development, eclipse, as one of the most popular integrated development environments, has provided convenience and efficiency to many developers. However, you may encounter garbled code problems when using eclipse, which brings trouble to project development and code reading. This article will introduce some effective methods to solve the problem of garbled characters in Eclipse and provide specific code examples. Modify eclipse file encoding settings: in eclip
