关于springMVC中web.xml配置问题

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/m1242832592/article/details/84754867
在使用eclipse创建maven项目时自动生成的web.xml文件
web.xml
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >

<web-app>
<display-name>Archetype Created Web Application</display-name>
</web-app>

而别人生成的web.xml文件好像都会带有如图这样的模式文件之类的配置

<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">


在网上看到很多人谈web.xml中的servlet配置、filter配置等等,却很少有人详细的讲到这些xsd文件,web.xml文件中会用到那些模式文件,用在什么地方,楼主就是因为不知道该如何添加这些模式文件,知道项目启动报错原因在哪却不知如何解决?
希望有大神能够给讲解一下。在此谢过!!!
展开阅读全文

关于filter的web.xml配置问题.

07-27

rn securityFilterrn security.SecurityFilterrn rnrn rn securityFilterrn /admin/*.jsprn rnrn为什么tomcat一启动就报错:rnjava.lang.IllegalArgumentException: Invalid /admin/*.jsp in filter mappingrn at org.apache.tomcat.util.digester.Digester.createSAXException(Digester.java:2726)rn at org.apache.tomcat.util.digester.Digester.createSAXException(Digester.java:2752)rn at org.apache.tomcat.util.digester.Digester.endElement(Digester.java:1061)rn at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:633)rn at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1241)rn at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1685)rn at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)rn at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)rn at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)rn at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)rn at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)rn at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1562)rn at org.apache.catalina.startup.ContextConfig.applicationWebConfig(ContextConfig.java:352)rn at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:1044)rn at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:261)rn at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)rn at org.apache.catalina.core.StandardContext.start(StandardContext.java:4148)rn at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1105)rn at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1203)rn at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:293)rn at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)rn at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1306)rn at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1570)rn at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1579)rn at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1559)rn at java.lang.Thread.run(Thread.java:595) 论坛

struts2 web.xml配置问题

01-05

为什么我在web.xml中增加rnrn struts2rn org.apache.struts2.dispatcher.Dispatcherrn rn rn struts2rn /*rn rn以上内容以后再启动TOMCAT以后报错,rn信息: SessionListener: contextInitialized()rn2009-1-5 14:15:57 org.apache.catalina.core.StandardContext filterStartrn严重: Exception starting filter struts2rnjava.lang.InstantiationException: org.apache.struts2.dispatcher.Dispatcherrn at java.lang.Class.newInstance0(Class.java:335)rn at java.lang.Class.newInstance(Class.java:303)rn at org.apache.catalina.core.ApplicationFilterConfig.getFilter (ApplicationFilterConfig.java:208)rn at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:302)rn at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:78)rn at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3635)rn at org.apache.catalina.core.StandardContext.start(StandardContext.java:4222)rn at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760)rn at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)rn at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)rn at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)rn at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)rn at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)rn at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)rn at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)rn at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)rn at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)rn at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)rn at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)rn at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)rn at org.apache.catalina.core.StandardService.start(StandardService.java:448)rn at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)rn at org.apache.catalina.startup.Catalina.start(Catalina.java:552)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)rn at java.lang.reflect.Method.invoke(Method.java:585)rn at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)rn at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)rn2009-1-5 14:15:57 org.apache.catalina.core.StandardContext startrn严重: Error filterStartrn2009-1-5 14:15:57 org.apache.catalina.core.StandardContext startrnrnrnrnrn但是我把LOG4J的JAR包放到WEB-INF/LIB目录下以后启动是没有问题了,但是浏览工程下的JSP页面,总是提示HTTP Status 404 这样的错误,找不到页面,rnrnrn是怎么回事了,rn 论坛

SpringMVC配置问题

07-07

Spring-Servlet.xml 文件如下:rnrnrn rn rnrn rn rn rn rn rn rn rn rn rn rn rn rn text/html;charset=UTF-8rn rn rn rn rnrn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rnrnrnJava代码如下:rnrn @RequestMapping("/list") rn public @ResponseBody List list(Model model ) rn NusersMapper nusermapper;rn List ulists= new ArrayList();rn //NusersMapper nuserMapper rn SqlSessionFactory sqlSessionFactory = BuildSqlsession.getSession();rn if (sqlSessionFactory!=null)rn SqlSession session = sqlSessionFactory.openSession();rn if (session!=null ) rn try rn nusermapper = session.getMapper(NusersMapper.class);rn ulists = nusermapper.selectByExample(new NusersExample());rn finally rn session.close();rn rn rn rn return ulists;rn rnrn运行时,总是出以下错误:rnrnexceptionrnjavax.servlet.ServletException: Servlet.init() for servlet Scanner threw exceptionrn org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:522)rn org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)rn org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)rn org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)rn org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:1096)rn org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)rn org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:760)rn org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1480)rn java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)rn java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)rn org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)rn java.lang.Thread.run(Unknown Source)rnrnrnroot causernorg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter#0' defined in ServletContext resource [/WEB-INF/Scanner-servlet.xml]: Cannot resolve reference to bean 'mappingJackson2HttpMessageConverter' while setting bean property 'messageConverters' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mappingJackson2HttpMessageConverter' defined in ServletContext resource [/WEB-INF/Scanner-servlet.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/ObjectMapperrn org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359)rn org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)rn org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:382)rn org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:157)rn org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1481)rn org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1226)rn org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)rn org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)rn org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)rn org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)rn org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)rn org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)rn org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:775)rn org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:861)rn org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541)rn org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:668)rn org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:634)rn org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:682)rn org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:553)rn org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:494)rn org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)rn javax.servlet.GenericServlet.init(GenericServlet.java:158)rn org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:522)rn org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)rn org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)rn org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)rn org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:1096)rn org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)rn org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:760)rn org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1480)rn java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)rn java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)rn org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)rn java.lang.Thread.run(Unknown Source)rnrnrnroot causernorg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mappingJackson2HttpMessageConverter' defined in ServletContext resource [/WEB-INF/Scanner-servlet.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/ObjectMapperrn org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1105)rn org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1050)rn org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510)rn org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)rn org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)rn org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)rn org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)rn org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)rn org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolvrn请各位大帮忙解决 论坛

没有更多推荐了,返回首页