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>  
  • 相关阅读:
    Python元组、列表、字典
    测试通过Word直接发布博文
    Python环境搭建(windows)
    hdu 4003 Find Metal Mineral 树形DP
    poj 1986 Distance Queries LCA
    poj 1470 Closest Common Ancestors LCA
    poj 1330 Nearest Common Ancestors LCA
    hdu 3046 Pleasant sheep and big big wolf 最小割
    poj 3281 Dining 最大流
    zoj 2760 How Many Shortest Path 最大流
  • 原文地址:https://www.cnblogs.com/friends-wf/p/3822559.html
Copyright © 2011-2022 走看看