码迷,mamicode.com
首页 > 编程语言 > 详细

springmvc最优化

时间:2014-07-07 00:19:16      阅读:242      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   java   color   文件   

java代码

 1 package com.tgb.web.controller.annotation;
 2 
 3 import javax.servlet.http.HttpServletRequest;
 4 
 5 import org.springframework.stereotype.Controller;
 6 import org.springframework.web.bind.annotation.RequestMapping;
 7 
 8 @Controller
 9 @RequestMapping("/user2")
10 public class User2Controller {
11     
12     @RequestMapping("/addUser")
13     public String addUser(HttpServletRequest request){
14         
15         String result ="this is addUser------优化版";
16         request.setAttribute("result", result);
17         return "/jquery";
18     }
19     
20     @RequestMapping("/delUser")
21     public String delUser(HttpServletRequest request){
22         String result ="this is delUser------优化版";
23         request.setAttribute("result", result);
24         return "/jquery";
25     }
26     @RequestMapping("/toUser")
27     public String toUser(HttpServletRequest request){
28         return "/jquery";
29     }
30 }

配置文件

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <beans xmlns="http://www.springframework.org/schema/beans"  
 3  xmlns:context="http://www.springframework.org/schema/context"  
 4  xmlns:p="http://www.springframework.org/schema/p"  
 5  xmlns:mvc="http://www.springframework.org/schema/mvc"  
 6  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
 7  xsi:schemaLocation="http://www.springframework.org/schema/beans  
 8       http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  
 9       http://www.springframework.org/schema/context  
10       http://www.springframework.org/schema/context/spring-context.xsd  
11       http://www.springframework.org/schema/mvc  
12       http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
13      <!-- 注解扫描包 -->
14     <context:component-scan base-package="com.tgb.web.controller.annotation" />
15     <!-- 开启注解 -->
16     
17     <mvc:annotation-driven/>
18     
19     <!-- <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
20     <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"></bean> -->
21     <!-- 静态资源访问 -->
22      <mvc:resources location="/img/" mapping="/img/**"/>  
23      <mvc:resources location="/js/" mapping="/js/**"/>   
24     
25 
26     <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
27         <property name="prefix" value="/"></property>
28         <property name="suffix" value=".jsp"></property>
29     </bean>
30  </beans>  

 

springmvc最优化,布布扣,bubuko.com

springmvc最优化

标签:style   blog   http   java   color   文件   

原文地址:http://www.cnblogs.com/friends-wf/p/3822559.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!