paip.spring3 mvc servlet的配置以及使用最佳实践
2014-04-09 22:33
190 查看
paip.spring3 mvc servlet的配置以及使用最佳实践
1. Web.xml 1
2. springMVC.xml 2
1. mvcAction .mvcAction 2
2. Resin4 发动跟踪mvc maping 3
3. No mapping found for HTTP request with URI 3
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/springMVC.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name> <!-- 这里在配成spring,下边也要写一个名为spring-servlet.xml的文件,主要用来配置它的controller -->
<url-pattern>*.json</url-pattern>
</servlet-mapping>
Xml的位置可以放得个多个地张儿..不过mvc还是放得个web-inf哈面儿好,不用铜布xml...减少部署的问题..
多个文件/WEB-INF/xxx/*.xml
classpath*:/springMVC.xml
作者Attilax 艾龙, EMAIL:1466519819@qq.com
来源:老哇的爪子 Attilax
地址:http://blog.csdn.net/attilax
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<mvc:default-servlet-handler/>
<mvc:annotation-driven />
<context:annotation-config />
<context:component-scan base-package="comapi.**,com.im"/>
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
</beans>
@RequestMapping("/im") 这个参数也能不代了...
public class mvcAction {
@RequestMapping(value = "/list3")
public void searchByKeyword2(String idxf, String keyword, int offset,
int limit, HttpServletResponse response) throws Exception {
response.getWriter().write("json txt");
}
只要更改class,biru添加一个方法,就能reload兰...生效兰...
1. Web.xml 1
2. springMVC.xml 2
1. mvcAction .mvcAction 2
2. Resin4 发动跟踪mvc maping 3
3. No mapping found for HTTP request with URI 3
1.Web.xml
<servlet><servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/springMVC.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name> <!-- 这里在配成spring,下边也要写一个名为spring-servlet.xml的文件,主要用来配置它的controller -->
<url-pattern>*.json</url-pattern>
</servlet-mapping>
Xml的位置可以放得个多个地张儿..不过mvc还是放得个web-inf哈面儿好,不用铜布xml...减少部署的问题..
多个文件/WEB-INF/xxx/*.xml
classpath*:/springMVC.xml
作者Attilax 艾龙, EMAIL:1466519819@qq.com
来源:老哇的爪子 Attilax
地址:http://blog.csdn.net/attilax
2.springMVC.xml
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<mvc:default-servlet-handler/>
<mvc:annotation-driven />
<context:annotation-config />
<context:component-scan base-package="comapi.**,com.im"/>
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
</beans>
1.mvcAction .mvcAction
@Controller@RequestMapping("/im") 这个参数也能不代了...
public class mvcAction {
@RequestMapping(value = "/list3")
public void searchByKeyword2(String idxf, String keyword, int offset,
int limit, HttpServletResponse response) throws Exception {
response.getWriter().write("json txt");
}
2.Resin4 发动跟踪mvc maping
发动resin的时候儿,能看见所有的生成的map url 了....feobye调试...3. No mapping found for HTTP request with URI
这个问题是更改孪注解的Url...但是,resin不reload....只要更改class,biru添加一个方法,就能reload兰...生效兰...
相关文章推荐
- paip.spring3 mvc servlet的配置以及使用最佳实践
- paip.python ide eric5-5.3.7 安装以及建立项目使用 最佳实践
- SpringBoot实践之---Druid连接池的使用和监控配置
- springboot 整合dubbo最佳实践 (使用redis作为注册中心)
- Spring在mac下的配置以及简单使用
- Java 安全套接字编程以及 keytool 使用最佳实践
- Java 安全套接字编程以及 keytool 使用最佳实践
- 第2.1.7章 WEB系统最佳实践Spring文件配置之spring-shiro.xml
- 第119讲:HDFS的配置以及安全高效的HDFS配置最佳实践学习笔记
- (转)iOS并发编程笔记,包含GCD,Operation Queues,Run Loops,如何在后台绘制UI,后台I/O处理,最佳安全实践避免互斥锁死锁优先级反转等,以及如何使用GCD监视进程文件文件夹,并发测试的方案等
- 第2.1.4章 WEB系统最佳实践Spring文件配置之spring-hessian-server.xml
- 第2.1.8章 WEB系统最佳实践Spring文件配置之spring-email.xml
- Spring学习之使用静态工厂方法以及实例工厂方法配置bean
- Spring的XML配置文件的十二个最佳方法实践
- Spring.net 控制反转(IOC)依赖注入(DI)的使用 以及Config文件的配置
- iOS并发编程笔记,包含GCD,Operation Queues,Run Loops,如何在后台绘制UI,后台I/O处理,最佳安全实践避免互斥锁死锁优先级反转等,以及如何使用GCD监视进程文件文件夹,并发测试的方案等
- Spring MVC整理系列(05)————Spring MVC配置解析及整合SpriSpring MVC之@ModelAttribute、@SessionAttributes以及Model的使用介绍
- java 使用memcached以及spring 配置memcached
- spring 事务注解配置以及实践
- Java 安全套接字编程以及 keytool 使用最佳实践