zoukankan      html  css  js  c++  java
  • springmvc最优化

    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>  
  • 相关阅读:
    Codeforces Round #276 (Div. 1) E. Sign on Fence 二分+主席树
    Codeforces Round #229 (Div. 2) C. Inna and Candy Boxes 树状数组s
    HDU 5918 Sequence I KMP
    HDU 5919 Sequence II 主席树
    hdu 5833 Zhu and 772002 高斯消元
    Codeforces Round #143 (Div. 2) E. Cactus 无向图缩环+LCA
    codeforces 45C C. Dancing Lessons STL
    deeplab hole algorithm
    有时候只是担心多余
    lstm
  • 原文地址:https://www.cnblogs.com/friends-wf/p/3822559.html
Copyright © 2011-2022 走看看