- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我是 Spring MVC 框架的新手。我正在尝试在 Eclipse Juno 和 Tomcat(V 7.0.61) 中使用 Spring 4 设置示例代码库。我尝试了不同论坛中所述的不同选项,但没有一个有效。非常感谢任何解决此问题的帮助!
下面是代码:
Web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>Spring MVC Application</display-name>
<servlet>
<servlet-name>HelloWeb</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>HelloWeb</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
HelloWeb-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">
<context:component-scan base-package="com.example.HelloController" />
<!-- <mvc:default-servlet-handler /> -->
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
</beans>
HelloController.java
package com.example;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
@RequestMapping("/hello")
public class HelloController{
@RequestMapping(method = RequestMethod.GET )
public String printHello(ModelMap model) {
model.addAttribute("message", "Hello Spring MVC Framework!");
return "hello";
}
}
服务器日志:
May 5, 2015 5:26:32 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:HelloWeb' did not find a matching property.
May 5, 2015 5:26:32 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version: Apache Tomcat/7.0.61
May 5, 2015 5:26:32 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built: Mar 27 2015 12:03:56 UTC
May 5, 2015 5:26:32 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server number: 7.0.61.0
May 5, 2015 5:26:32 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name: Windows 7
May 5, 2015 5:26:32 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version: 6.1
May 5, 2015 5:26:32 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture: x86
May 5, 2015 5:26:32 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Java Home: C:\Program Files (x86)\Java\jdk1.6.0_31\jre
May 5, 2015 5:26:32 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version: 1.6.0_31-b05
May 5, 2015 5:26:32 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor: Sun Microsystems Inc.
May 5, 2015 5:26:32 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE: C:\U175827\Workspaces\jBpm\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
May 5, 2015 5:26:32 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME: C:\U175827\apache-tomcat-7.0.61
May 5, 2015 5:26:32 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=C:\U175827\Workspaces\jBpm\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
May 5, 2015 5:26:32 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=C:\U175827\apache-tomcat-7.0.61
May 5, 2015 5:26:32 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dwtp.deploy=C:\U175827\Workspaces\jBpm\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps
May 5, 2015 5:26:32 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.endorsed.dirs=C:\U175827\apache-tomcat-7.0.61\endorsed
May 5, 2015 5:26:32 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dfile.encoding=Cp1252
May 5, 2015 5:26:32 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Xbootclasspath:C:\Program
May 5, 2015 5:26:32 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: Files
May 5, 2015 5:26:32 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: (x86)\Java\jdk1.6.0_31\jre\lib\resources.jar;C:\Program
May 5, 2015 5:26:32 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: Files
May 5, 2015 5:26:32 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: (x86)\Java\jdk1.6.0_31\jre\lib\rt.jar;C:\Program
May 5, 2015 5:26:32 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: Files
May 5, 2015 5:26:32 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: (x86)\Java\jdk1.6.0_31\jre\lib\jsse.jar;C:\Program
May 5, 2015 5:26:32 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: Files
May 5, 2015 5:26:32 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: (x86)\Java\jdk1.6.0_31\jre\lib\jce.jar;C:\Program
May 5, 2015 5:26:32 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: Files
May 5, 2015 5:26:32 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: (x86)\Java\jdk1.6.0_31\jre\lib\charsets.jar;C:\U175827\jboss-5.1.0.GA-jdk6\jboss-5.1.0.GA\common\lib\servlet-api.jar
May 5, 2015 5:26:32 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files (x86)\Java\jdk1.6.0_31\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/U175827/eclipse/jre/bin/client;C:/U175827/eclipse/jre/bin;C:/U175827/eclipse/jre/lib/i386;C:\Program Files (x86)\Java\jdk1.6.0_31\bin;C:\Program Files (x86)\Java\jdk1.6.0_31\jre\bin;C:\Oracle\product\11.2.0\client_1\bin\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Microsoft Application Virtualization Client;C:\Program Files\Citrix\ICAService\;C:\Program Files\Citrix\System32\;C:\Program Files (x86)\Microsoft SQL Server\80\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\90\Tools\binn\;C:\Program Files (x86)\Microsoft SQL Server\90\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files (x86)\Windows Kits\8.0\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Common Files\Citrix\System32\;C:\U175827\unix-utils;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\U175827\eclipse;;.
May 5, 2015 5:26:32 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8082"]
May 5, 2015 5:26:32 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8010"]
May 5, 2015 5:26:32 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1809 ms
May 5, 2015 5:26:32 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
May 5, 2015 5:26:32 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.61
May 5, 2015 5:26:33 PM org.apache.tomcat.websocket.server.WsSci onStartup
INFO: JSR 356 WebSocket (Java WebSocket 1.1) support is not available when running on Java 6. To suppress this message, run Tomcat on Java 7, remove the WebSocket JARs from $CATALINA_HOME/lib or add the WebSocket JARs to the tomcat.util.scan.DefaultJarScanner.jarsToSkip property in $CATALINA_BASE/conf/catalina.properties. Note that the deprecated Tomcat 7 WebSocket API will be available.
May 5, 2015 5:26:33 PM org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom
INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [329] milliseconds.
May 5, 2015 5:26:36 PM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
May 5, 2015 5:26:36 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'HelloWeb'
May 5, 2015 5:26:36 PM org.springframework.web.servlet.DispatcherServlet initServletBean
INFO: FrameworkServlet 'HelloWeb': initialization started
May 5, 2015 5:26:36 PM org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh
INFO: Refreshing WebApplicationContext for namespace 'HelloWeb-servlet': startup date [Tue May 05 17:26:36 IST 2015]; root of context hierarchy
May 5, 2015 5:26:36 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/HelloWeb-servlet.xml]
May 5, 2015 5:26:38 PM org.springframework.web.servlet.DispatcherServlet initServletBean
INFO: FrameworkServlet 'HelloWeb': initialization completed in 1750 ms
May 5, 2015 5:26:38 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8082"]
May 5, 2015 5:26:38 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8010"]
May 5, 2015 5:26:38 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 5487 ms
May 5, 2015 5:26:45 PM org.springframework.web.servlet.PageNotFound noHandlerFound
WARNING: No mapping found for HTTP request with URI [/HelloWeb/hello] in DispatcherServlet with name 'HelloWeb'
我正在使用的网址:
http://localhost:8082/HelloWeb/hello
最佳答案
您需要将其添加到您的web.xml
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/HelloWeb-servlet.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
关于java - org.springframework.web.servlet.PageNotFound noHandlerFound警告: No mapping found for HTTP request with URI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30052420/
我有一个关于 Java Servlet 的问题。 假设我在 servlet 网页“somePage”上。我想登录(使用另一个 servlet,“登录”servlet)。所以我点击“somePage”上
如何将变量数组从一个 servlet 传递到另一个 servlet? 最佳答案 如果您要将当前请求传递给另一个servlet,则只需将其设置为请求属性即可。 request.setAttribute(
什么可能导致此错误? Caused by: jakarta.servlet.UnavailableException: Servlet class org.restlet.ext.servle
我的maven依赖树是这样的 我想问我maven如何解决这个冲突,有两个servlet-api.jar?提前谢谢你。 最佳答案 如果您想从 Velocity 工具中删除 servlet-api,您可以
config ProcessReg ProcessReg text HelloWorld1 public class config implements Serv
您好,我有一个关于 servlet 调用另一个 servlet 的问题 我有一个名为 Relay 的主 servlet,它将负责控制其他 servlet 用户将点击并将转发到 Relay servle
在我的 REST API 项目中,我已将 /* 映射到 RESTServlet,并且需要在同一 WAR 中托管静态内容。我更愿意将 /static/* 映射到 WAS liberty 提供的默认 se
响应映射在 Servlet 中如何工作? 每个响应如何知道清除特定 HTML 或 Handlebars 上的输出? 最佳答案 有一个 ember-java带有 Jersey REST 服务 的 git
有一个 @WebServlet(urlPatterns = "/myServlet/") .如果用户转到 myapp/myServlet/other ,我仍然希望我的 servlet 能够捕获。也就是
我正在使用 Filter 在我的所有页面中插入反点击劫持 header - 这工作正常,除了 JBoss EAP 6.3 容器管理的登录页面,这是更重要的页面之一拥有它。 登录页面根本不调用过滤器,登
我正在尝试使用 RequestDispatcher 将数据从一个 servlet 传递到另一个 servlet。这是我的调度程序代码。 String address; address = "/Java
我刚刚开始使用 Servlet,并设法让一些 Servlet 充当单独的 URL,用于填充数据库以进行一些虚拟测试。某种形式: public class Populate_ServletName ex
我是否需要同时配置app.servlet.version 和 grails.servlet.version? 前者在application.properties中,后者在BuildConfig.gro
在Myeclipse中我创建了一个名为web1的Web项目,并添加了一个名为servlet1的servlet,web.xml如下: servlet1 servlet1
这个问题在这里已经有了答案: How to run a background task in a servlet based web application? (5 个回答) 6年前关闭。 是否可以在
在我的 ManagedBean 中,如果我将范围从 @RequestScoped 更改为 @ViewScoped,我将收到以下错误堆栈。我该如何解决这个问题?不过,当我运行应用程序时,我可以在页面中看
这个问题已经有答案了: How do I execute multiple servlets in sequence? (2 个回答) 已关闭 3 年前。 我已经构建了jdbc-Servlet的代码,
我一直在徒劳地尝试实现 tomcat 9 的 jakarta servlet,而不是以前的 javax.servlet 实现(因为我的理解是 jakarta 包是前进的方向)。问题是,当我将浏览器指向
我是 Spring 新手,正在尝试使用 Maven 部署和运行我的第一个 Spring Web 应用程序。有关更多详细信息,请参阅 here (我昨天发布的一个问题): 现在,我遇到的问题是:当我尝试
我正在尝试学习如何使用 JSP。我遇到了一些毫无意义的事情,至少在我看来是这样: 当我尝试运行时: response.getWriter().println(m.getDb().printAll())
我是一名优秀的程序员,十分优秀!