. Factory. beanfactory;
ImportOrg. springframework. Context. Support. classpathxmlapplicationcontext;
//We used to usePropertiesFile to read information,Obtain the name of the class. Then, we get the object of this class through reflection.
PublicClassTest {
/**
*@ ParamARGs
*@ ThrowsIoexception
*/
PublicStaticVoidMain (string [] ARGs)ThrowsException {
//PassXMLFile to read information
//BecauseXMLTherefore, the reading method is different.
Beanfactory F =NewClasspathxml
Surpassing yesterday's series (4)
Building a project using Maven has many advantages. We strongly recommend that you use Maven for initial project construction. The Log Module isProject. Modules are spliced to learn how to build a complete and awesome project.
With this command, a project is automatically created:
MVN archetype: Create-dgroupid = com. oreilly-dartifactid = My-app
Generate a project directory like this:
Recommended:
In
You can query the dependency of POM. xml on
" Xmlns: xsi = "Http://www.w3.org/2001/XMLSchema-instance" > Path of the providers. config file, the Project Name of the Web Application --> Properties Embedded = "Yoursolution. Web. properties. config, yoursolution. Web" /> Settings > Setting Usestatementnamespaces = "False" /> Settings > Providers Resource = "Config/providers. config" /> Database > The parameters are set in properties. config.
://www.springframework.net " xmlns: xsi =" http://www.w3.org/2001/XMLSchema-instance " xsi: schemalocation =" http://www.springframework.net http://www.springframework.net/xsd/spring-objects.xsd " > ObjectID= "Springtest"Type= "Piggywinformtemplet. springtest, piggywinform"/> Objects> The configuration has been completed. Next, I paste the spring container class that I have encapsulated to fa
Jpa2.0 is integrated with spring, and the persistence. xml file can be required or not.
For persistence. XML, you only need to make the following simple configuration:
XML version = "1.0" encoding = "UTF-8" ?> Persistence Version = "2.0" Xmlns = "Http://java.sun.com/xml/ns/persistence" Xmlns: xsi = "Http://www.w3.org/2001/XMLSchema-instance" Xsi: schemalocation = "Http://java.sun.com/xml/ns
you can see an interesting application, Turn it off, huh, huh !!
1. definition class myfunction ( note: method must be Public static)
Package Com. tgb. jstl;
/**
* UDF implementation class in the jstl label*
*/
Public
Class Myfunctions {
Public
Static String sayhello (string name ){
Return "Hello" + name;
}
}
2.ProvideTLDDescription file,This file can be placed inWEB-INFOr under its Directory.
XML version = "1.0" encoding = "UTF-8"
?>
Tagli
://java.sun.com/xml/ns/j2ee"
Xmlns: xsi =Http://www.w3.org/2001/XMLSchema-instance"
Xsi: schemalocation =Http://java.sun.com/xml/ns/j2ee web-jsptaglibrary_2_0.xsd">
Mytaglib
3. Configure web. xml
Mytaglib
/WEB-INF/mytaglib. TLD
4. Import it in the header of the JSP page that requires this tag
5. Use (refer to the above st
1) create a webproject
2) Add the jar package required for struts Development (8 in total) to the WEB-INF/lib
3) copy the prepared raw web. xml and struts-config.xml files to the WEB-INF directory
Content of the web. xml file:
Xmlns = "http://java.sun.com/xml/ns/javaee"Xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"Xsi: schemalocation = "http://java.sun.com/xml/ns/javaeeHttp://java.sun.co
Xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" version = "2.5"
Xsi: schemalocation = "http://java.sun.com/xml/ns/javaee
Http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd>
// Use spring characterencodingfilter
Org. springframework. Web. Filter. characterencodingfilter
// The UTF-8 encoding is used after the filter is filtered.
// Filter all paths:/* indicates
I. Spring configuration file
The spring namespace is used here, as follows:
Xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns: context = "http://www.springframework.org/schema/context"Xmlns: Tx = "http://www.springframework.org/schema/tx"Xsi: schemalocation = "http://www.springframework.org/schema/beansHttp://www.springframework.org/schema/beans/spring-beans-2.5.xsdHttp://www.springframewor
= "NONE">
After configuring these above, you need to create a WEB-INF under the ntx-servlet.xml as follows:
Next, specify which requests will be sent to spring's dispatcherservlet for processing. Therefore, add
To load configuration files such as dispatcherservlet correctly. configure a context loader contextloaderlistener or contextloaderservlet in XML. Here we use the second method to be compatible with the Serlvet container of a lo
1. Develop entity classes
Package Com. Persia. JPA; Import Javax. Persistence. entity; Import Javax. Persistence. generatedvalue; Import Javax. Persistence. ID; @ entity Public Class Person { Private Int ID; Private String name; @ ID @ generatedvalue Public Int GETID (){ Return ID ;}Public Void Setid ( Int ID ){ This . ID = ID ;} Public String getname (){ Return Name ;} Public Void Setname (string name ){ This . Name = Name ;}}
2. Add the hibernate attribute in persistence. XML t
the dynamic-attributes attribute for the tag that supports dynamic attributes in the tag description file javayou. TLD. The value is true. The configuration in this example is as follows:
Xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"Xsi: schemalocation = "http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"Version = "2.0">
Create a new project struts2 project teaweb (because the project is now done on a tea, tea culture), import jar packages (Basic jar packages: commons-logging-1.0.4.jar, freemarker-2.3.8.jar, ognl-2.6.11.jar, struts2-core-2.0.10.jar, xwork-2.0.4.jar), configure struts. the xml configuration is as follows:
"-// Apache Software Foundation // DTD struts configuration 2.0 // en"Http://struts.apache.org/dtds/struts-2.0.dtd>
Note the following:Extends = "JSON-Default",
Configure web. XML as
query records.
The client can use serialization to convert the list into XML. However, there are some minor problems in the serialization process.
1. Net default is UTF-16, SQL only know UTF-8
2. Appearing annoying xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns: XSD = "http://www.w3.org/2001/XMLSchema"
You can use this class
Public Static Class Serializehelper { Private Static Readonly Xmlserializernamespaces namesp
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.