为方便起见,使用oracle自带的scott账户中的emp表作为数据源。

预期效果:

1.输入URL:http://localhost:8888/ssm/getEmp?empno=7369

2.返回结果如下:

ssm框架搭建并演示获取json字符串

实现过程:

1.引入所需jar包:

  1 <dependencies>
  2     <dependency>  
  3            <groupId>jstl</groupId>  
  4            <artifactId>jstl</artifactId>  
  5            <version>1.1.2</version>  
  6        </dependency>
  7        <!-- https://mvnrepository.com/artifact/taglibs/standard -->
  8 <dependency>
  9     <groupId>taglibs</groupId>
 10     <artifactId>standard</artifactId>
 11     <version>1.1.2</version>
 12 </dependency>
 13 <dependency>  
 14             <groupId>com.fasterxml.jackson.core</groupId>  
 15             <artifactId>jackson-core</artifactId>  
 16             <version>2.8.9</version>
 17         </dependency>  
 18           <dependency>
 19             <groupId>com.fasterxml.jackson.core</groupId>  
 20             <artifactId>jackson-databind</artifactId>  
 21             <version>2.8.9</version>  
 22         </dependency>
 23         <dependency>  
 24             <groupId>com.fasterxml.jackson.core</groupId>  
 25             <artifactId>jackson-annotations</artifactId>  
 26             <version>2.8.9</version>  
 27         </dependency>  
 28     <dependency>
 29       <groupId>junit</groupId>
 30       <artifactId>junit</artifactId>
 31       <version>3.8.1</version>
 32       <scope>test</scope>
 33     </dependency>
 34       <!-- mybatis-generator-core核心jar包 -->  
 35 <dependency>  
 36     <groupId>org.mybatis.generator</groupId>  
 37     <artifactId>mybatis-generator-core</artifactId>  
 38     <version>1.3.2</version>  
 39 </dependency> 
 40 <!-- c3p0连接池 --><!-- https://mvnrepository.com/artifact/c3p0/c3p0 -->
 41 <dependency>
 42     <groupId>c3p0</groupId>
 43     <artifactId>c3p0</artifactId>
 44     <version>0.9.1.2</version>
 45 </dependency>
 46 
 47 <!-- 添加连接Oracle的jar包 -->
 48 <!-- https://mvnrepository.com/artifact/ojdbc/ojdbc -->
 49 <dependency>
 50     <groupId>ojdbc</groupId>
 51     <artifactId>ojdbc</artifactId>
 52     <version>14-10gR3</version>
 53 </dependency>
 54     <!-- Spring4.3.3 -->
 55    <!-- https://mvnrepository.com/artifact/org.springframework/spring-web -->
 56 <dependency>
 57     <groupId>org.springframework</groupId>
 58     <artifactId>spring-web</artifactId>
 59     <version>4.3.3.RELEASE</version>
 60 </dependency>
 61 <!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
 62 <dependency>
 63     <groupId>org.springframework</groupId>
 64     <artifactId>spring-webmvc</artifactId>
 65     <version>4.3.3.RELEASE</version>
 66 </dependency>
 67 <!-- https://mvnrepository.com/artifact/net.sf.json-lib/json-lib-ext-spring 
 68 <dependency>
 69     <groupId>net.sf.json-lib</groupId>
 70     <artifactId>json-lib-ext-spring</artifactId>
 71     <version>1.0.2</version>
 72 </dependency>-->
 73 <!-- https://mvnrepository.com/artifact/org.codehaus.jackson/jackson-mapper-asl -->
 74 <dependency>
 75     <groupId>org.codehaus.jackson</groupId>
 76     <artifactId>jackson-mapper-asl</artifactId>
 77     <version>1.9.13</version>
 78 </dependency>
 79 <!-- https://mvnrepository.com/artifact/org.codehaus.jackson/jackson-mapper-lgpl -->
 80 <dependency>
 81     <groupId>org.codehaus.jackson</groupId>
 82     <artifactId>jackson-mapper-lgpl</artifactId>
 83     <version>1.9.13</version>
 84 </dependency>
 85 <!-- https://mvnrepository.com/artifact/org.codehaus.jackson/jackson-core-asl -->
 86 <dependency>
 87     <groupId>org.codehaus.jackson</groupId>
 88     <artifactId>jackson-core-asl</artifactId>
 89     <version>1.9.13</version>
 90 </dependency>
 91 <!-- https://mvnrepository.com/artifact/org.codehaus.jackson/jackson-core-lgpl -->
 92 <dependency>
 93     <groupId>org.codehaus.jackson</groupId>
 94     <artifactId>jackson-core-lgpl</artifactId>
 95     <version>1.9.13</version>
 96 </dependency>
 97 <!-- https://mvnrepository.com/artifact/org.springframework/spring-jdbc -->
 98 <dependency>
 99     <groupId>org.springframework</groupId>
100     <artifactId>spring-jdbc</artifactId>
101     <version>4.3.3.RELEASE</version>
102 </dependency>
103 <!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
104 <dependency>
105     <groupId>org.springframework</groupId>
106     <artifactId>spring-context</artifactId>
107     <version>4.3.3.RELEASE</version>
108 </dependency>
109 <!-- https://mvnrepository.com/artifact/org.springframework/spring-core -->
110 <dependency>
111     <groupId>org.springframework</groupId>
112     <artifactId>spring-core</artifactId>
113     <version>4.3.3.RELEASE</version>
114 </dependency>
115 <!-- https://mvnrepository.com/artifact/org.springframework/spring-aop -->
116 <dependency>
117     <groupId>org.springframework</groupId>
118     <artifactId>spring-aop</artifactId>
119     <version>4.3.3.RELEASE</version>
120 </dependency>
121 <!-- 与spring-aop相关的jar包 -->
122 <!-- https://mvnrepository.com/artifact/aopalliance/aopalliance -->
123 <dependency>
124     <groupId>aopalliance</groupId>
125     <artifactId>aopalliance</artifactId>
126     <version>1.0</version>
127 </dependency>
128 <!-- https://mvnrepository.com/artifact/org.aspectj/aspectjrt -->
129 <dependency>
130     <groupId>org.aspectj</groupId>
131     <artifactId>aspectjrt</artifactId>
132     <version>1.8.9</version>
133 </dependency>
134 <!-- https://mvnrepository.com/artifact/org.aspectj/aspectjweaver -->
135 <dependency>
136     <groupId>org.aspectj</groupId>
137     <artifactId>aspectjweaver</artifactId>
138     <version>1.8.9</version>
139 </dependency>
140 <!-- Junit -->
141 <!-- https://mvnrepository.com/artifact/junit/junit -->
142 <dependency>
143     <groupId>junit</groupId>
144     <artifactId>junit</artifactId>
145     <version>4.10</version>
146 </dependency>
147 <!-- JSR303验证 -->
148 <!-- https://mvnrepository.com/artifact/javax.validation/validation-api -->
149 <dependency>
150     <groupId>javax.validation</groupId>
151     <artifactId>validation-api</artifactId>
152     <version>1.1.0.Final</version>
153 </dependency>
154 <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-validator -->
155 <dependency>
156     <groupId>org.hibernate</groupId>
157     <artifactId>hibernate-validator</artifactId>
158     <version>5.2.4.Final</version>
159 </dependency>
160 
161 <!-- 重写equals和hashCode方法的包 -->
162 <!-- https://mvnrepository.com/artifact/commons-lang/commons-lang -->
163 <dependency>
164     <groupId>commons-lang</groupId>
165     <artifactId>commons-lang</artifactId>
166     <version>2.6</version>
167 </dependency>
168 <!-- tiles页面布局 -->
169     <!-- https://mvnrepository.com/artifact/org.apache.tiles/tiles-jsp -->
170 <dependency>
171     <groupId>org.apache.tiles</groupId>
172     <artifactId>tiles-jsp</artifactId>
173     <version>3.0.7</version>
174 </dependency>
175 <!-- log4j -->
176 <!-- https://mvnrepository.com/artifact/log4j/log4j -->
177 <dependency>
178     <groupId>log4j</groupId>
179     <artifactId>log4j</artifactId>
180     <version>1.2.17</version>
181 </dependency>
182 <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-ext -->
183 <dependency>
184     <groupId>org.slf4j</groupId>
185     <artifactId>slf4j-ext</artifactId>
186     <version>1.5.10</version>
187 </dependency>
188 <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
189 <dependency>
190     <groupId>org.slf4j</groupId>
191     <artifactId>slf4j-api</artifactId>
192     <version>1.5.10</version>
193 </dependency>
194 <!-- https://mvnrepository.com/artifact/org.slf4j/jcl-over-slf4j -->
195 <dependency>
196     <groupId>org.slf4j</groupId>
197     <artifactId>jcl-over-slf4j</artifactId>
198     <version>1.5.10</version>
199 </dependency>
200 <!-- slf4j -->
201 <dependency>
202     <groupId>org.slf4j</groupId>
203     <artifactId>slf4j-log4j12</artifactId>
204     <version>1.5.10</version>
205 </dependency>
206 <!-- AspectJ -->
207 <!-- https://mvnrepository.com/artifact/org.aspectj/aspectjrt -->
208 <dependency>
209     <groupId>org.aspectj</groupId>
210     <artifactId>aspectjrt</artifactId>
211     <version>1.8.9</version>
212 </dependency>
213 <!-- SpringMVC文件上传 -->
214 <!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
215 <dependency>
216     <groupId>commons-io</groupId>
217     <artifactId>commons-io</artifactId>
218     <version>2.4</version>
219 </dependency>
220 <!-- https://mvnrepository.com/artifact/commons-fileupload/commons-fileupload -->
221 <dependency>
222     <groupId>commons-fileupload</groupId>
223     <artifactId>commons-fileupload</artifactId>
224     <version>1.3.1</version>
225 </dependency>
226   <!-- https://mvnrepository.com/artifact/org.mybatis/mybatis -->
227 <dependency>
228     <groupId>org.mybatis</groupId>
229     <artifactId>mybatis</artifactId>
230     <version>3.4.1</version>
231 </dependency>
232   <!-- https://mvnrepository.com/artifact/org.mybatis/mybatis-spring -->
233 <dependency>
234     <groupId>org.mybatis</groupId>
235     <artifactId>mybatis-spring</artifactId>
236     <version>1.3.0</version>
237 </dependency>
238 
239 </dependencies>
pom.xml

相关文章:

  • 2021-09-13
猜你喜欢
  • 2022-12-23
  • 2021-12-27
  • 2021-12-25
  • 2021-11-29
  • 2021-11-27
  • 2021-11-27
相关资源
相似解决方案