The technology used
Background technology: Spring SPRINGMVC Mybatis (NO).
Foreground technology: HTML, CSS, JS
If you do not use MyBatis, the product's data comes from. – from MySQL Database
Ways to get Data:
1. Getting from JDBC
A) advantages
I. Direct, access to short, simple
b) Disadvantages
I. Data is unsafe for back-end system teams (as long as the open account is a read-only account)
Ii. the front-end system team needs to have the learning cost to use the database
Iii. dependency, coupling is too high, the backend team modifies the database structure, then other teams must follow the change logic to use
Iv. go directly to the database query, unable to add cache logic
2, through the background system interface to obtain
A) advantages
I. The coupling is reduced, and the back-end team simply ensures that the return data format of the interface does not change, and other teams do not need to upgrade
II. Data security
Iii. front-end team does not need to learn the underlying database structure of the backend team
Iv. back-end teams can add cache logic at the interface
b) Disadvantages
I. Get a long path (not a real disadvantage) create Taotao-web
Import Dependency
<project xmlns= "http://maven.apache.org/POM/4.0.0" xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xsi: schemalocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" > <
Modelversion>4.0.0</modelversion> <parent> <groupId>com.taotao.parent</groupId> <artifactId>taotao-parent</artifactId> <version>0.0.1-SNAPSHOT</version> </parent>
; <groupId>com.taotao.web</groupId> <artifactId>taotao-web</artifactId> <version>
0.0.1-snapshot</version> <packaging>war</packaging> <dependencies> <dependency> <groupId>com.taotao-common</groupId> <artifactid>taotao-common</artifactid
> <version>0.0.1-SNAPSHOT</version> </dependency> <!--unit Testing-- <dependency> <groupid>juniT</groupid> <artifactId>junit</artifactId> <scope>test</scope>
</dependency> <dependency> <groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> </depe Ndency> <!--Jackson JSON processing Toolkit--<dependency> <GROUPID>COM.FASTERXML.J
Ackson.core</groupid> <artifactId>jackson-databind</artifactId> </dependency> <!--JSP related <dependency> <groupId>jstl</groupId> <a rtifactid>jstl</artifactid> </dependency> <dependency> <groupid>jav Ax.servlet</groupid&gT <artifactId>servlet-api</artifactId> <scope>provided</scope> </DEPENDENCY&G
T <dependency> <groupId>javax.servlet</groupId> <artifactid>jsp-api</arti
Factid> <scope>provided</scope> </dependency> <!--Apache Tool components-- <dependency> <groupId>org.apache.commons</groupId> <artifactid>com mons-lang3</artifactid> </dependency> <dependency> <groupid>org.apache .commons</groupid> <artifactId>commons-io</artifactId> </dependency> </ Dependencies> <build> <plugins> <!--configuring Tomcat plug-in and <plugin&
Gt <groupId>org.apache.tomcat.maven</groupId> <artifactid>tomcat7-mavEn-plugin</artifactid> <configuration> <port>8082</port> <path>/</path> </configuration> </plugin> </ Plugins> </build> </project>
Web. Xml
<?xml version= "1.0" encoding= "UTF-8"?> <web-app xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xmlns= "Http://java.sun.com/xml/ns/javaee" xsi:schemalocation= "Http://java.sun.com/xml/ns/javaee/http Java.sun.com/xml/ns/javaee/web-app_2_5.xsd "id=" webapp_id "version=" 2.5 "> <display-name>taotao-web</d Isplay-name> <context-param> <param-name>contextConfigLocation</param-name> < Param-value>classpath:spring/applicationcontext*.xml</param-value> </context-param> <!--spring ApplicationContext load-up <listener> <listener-class>org.springframework.web.context.contextlo Aderlistener</listener-class> </listener> <!--coded filters, UTF8-in <filter> < ;filter-name>encodingfilter</filter-name> <filter-class> Org.springframework.web.filter.characterencodingfilter</filter-class> <iniT-param> <param-name>encoding</param-name> <param-value>utf8</param-value&
Gt </init-param> </filter> <filter-mapping> <filter-name>encodingfilter</filter-na
Me> <url-pattern>/*</url-pattern> </filter-mapping> <!--configuration Springmvc Frame Entry-- <servlet> <servlet-name>taotao-web</servlet-name> <servlet-class>org.springfram Ework.web.servlet.dispatcherservlet</servlet-class> <init-param> <param-name>context Configlocation</param-name> <PARAM-VALUE>CLASSPATH:SPRING/TAOTAO-WEB-SERVLET.XML</PARAM-VALUE&G
T </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping > <servlet-name>taotao-web</servlet-name> <!--pseudo-static facilitates SEO (search engine Excellent<url-pattern>*.html</url-pattern> </servlet-mapping> <welcome-fil e-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app>
Spring and SPRINGMVC configuration files
<beans xmlns= "Http://www.springframework.org/schema/beans" xmlns:context= "http://www.springframework.org/ Schema/context "xmlns:p=" http://www.springframework.org/schema/p "xmlns:aop=" http://www.springframework.org/ Schema/aop "xmlns:tx=" Http://www.springframework.org/schema/tx "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-4.0.xsd Http://www.springframework.org/schema/context/HTTP Www.springframework.org/schema/context/spring-context-4.0.xsd HTTP://WWW.SPRINGFRAMEWORK.ORG/SCHEMA/AOP/HTTP Www.springframework.org/schema/aop/spring-aop-4.0.xsd HTTP://WWW.SPRINGFRAMEWORK.ORG/SCHEMA/TX/HTTP Www.springframework.org/schema/tx/spring-tx-4.0.xsd Http://www.springframework.org/schema/util/HTTP Www.springframework.org/schema/util/spring-util-4.0.xsd "> <!--using spring's own placeholder replacement function--<bean C Lass= "Org.springfraMework.beans.factory.config.PropertyPlaceholderConfigurer "> <!--allow JVM parameters to be overwritten--<!--java-djdb C.url=123-jar Xxx.jar--<property name= "Systempropertiesmodename" value= "System_properties_mode_override" /> <!--Ignore resource file not found--<property name= "Ignoreresourcenotfound" value= "true"/> &L t;! --Configure resource Files--<property name= "Locations" > <list> <value>classpath :env.properties</value> </list> </property> </bean> <!--scan package-->
;
<context:component-scan base-package= "Com.taotao"/> </beans>
<?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" xmlns:context= "Http://www.springframework.org/schema/context" xmlns:mvc= "Http://www.springframework.org/schema/mvc" xsi: schemalocation= "Http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/ Spring-beans-4.0.xsd Http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/ Spring-mvc-4.0.xsd Http://www.springframework.org/schema/context http://www.springframework.org/schema/context/
Spring-context-4.0.xsd "> <!--Notes Driver--<mvc:annotation-driven/> <!--scan Controller--
<context:component-scan base-package= "Com.taotao.web.controller"/> <!--View Parser--<!-- example:prefix= "/web-inf/jsp/", suffix= ". JSP", viewname= "test", "/Web-inf/jsp/test.jsp "-<bean class=" Org.springframework.web.servlet.view.InternalResourceViewResolver "&
Gt <property name= "prefix" value= "/web-inf/views/"/> <property name= "suffix" value= ". jsp"/> </bean > </beans>
Importing static files
Writing Indexcontroller
Package Com.taotao.web.controller;
Import Org.springframework.stereotype.Controller;
Import org.springframework.web.bind.annotation.RequestMapping;
Import Org.springframework.web.bind.annotation.RequestMethod;
Import Org.springframework.web.servlet.ModelAndView;
@RequestMapping ("index")
@Controller public
class Indexcontroller {
/**
* Home
* *
@return
*
/@RequestMapping (method = requestmethod.get) public
Modelandview Index () {
Modelandview mv = New Modelandview ("index");
return mv;
}
}
Configuring hosts and Nginx
To run a test discovery:
Www.taotao.com will not find the page:
www.taotao.com/index.html to get the page
Because the input www.taotao.com, the default is to find the index.jsp, does not meet the *.html rules.
re-Test after modification: