Componentize java and web code into jar packages

1. Code structure (web part)


 Static files are placed under META-INF>resources, jsp is placed under META-INF>resources>WEB-INF>views

 

2.mvc configuration

<mvc:annotation-driven /> -- enable annotation

 

<mvc:default-servlet-handler /> -- handles static files

 

<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">

<property name="prefix" value="/WEB-INF/views/" />

<property name="suffix" value=".jsp" />

 </bean> --Controller转JSP

 

<mvc:resources mapping="/resources/**" location="classpath:/META-INF/resources/"/> -- static file mapping

 

<mvc:resources mapping="/WEB-INF/views/**" location="classpath:/META-INF/resources/WEB-INF/views/"/> --jsp映射

 

3.pom.xml

<?xml version="1.0"?>

<project

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"

xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<modelVersion>4.0.0</modelVersion>

<groupId>com.asiainfo</groupId>

<artifactId>aigov-view</artifactId>

<name>aigov-view</name>

<version>1.0.0</version>

<url>http://maven.apache.org</url>

<properties>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

</properties>

</project>

Execute Run As->Maven install to generate the jar package

 

4. Precautions

JDK uses 1.7 and above, Tomcat uses 7 and above

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326677472&siteId=291194637