我是学习Spring MVC的新手。我的计划列表如下。我的src/MySpringMVCProjects
文件夹中有一个控制器。我在控制器类中,在Exception,String和getParameter行上获得了多个错误标记。
package MySpringMVCProjects;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
public class HelloController implements Controller {
public ModelAndView handleRequest(HttpServletRequest req,
HttpServletResponse res) throws Exception {
String name = req.getParameter("name");
Map m = new HashMap();
m.put("msg", "Hello" + name);
ModelAndView mav = new ModelAndView("success", m);
return mav;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >
<display-name>FirstMVCHelloWorld</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<!-- default -->
<servlet>
<servlet-name>HelloController</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloController</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
</web-app>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
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-2.5.xsd">
<!-- default handler mapping -->
<!-- handler -->
<bean class = "org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"/>
<!-- controller -->
<bean name = "/hello.htm" class = "MySpringMVCProjects.HelloController" />
<!-- view resolver -->
<bean class = "org.springframework.web.servlet.view.InternalResourceViewResolver" >
<property name = "prefix" value ="/" />
<property name = "suffix" value =".jsp" />
</bean>
</beans>
<h1>HelloWorld</h1>
<form action = "./hello.htm">
NAME:<input type="text" value="name"/>
<input type="submit" value="sayHello"/>
</form>
${msg}
Oct 09, 2015 1:25:15 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:SimpleWebService' did not find a matching property.
Oct 09, 2015 1:25:15 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:FirstMVCHelloWorld' did not find a matching property.
Oct 09, 2015 1:25:15 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version: Apache Tomcat/7.0.64
Oct 09, 2015 1:25:15 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built: Aug 19 2015 17:18:06 UTC
Oct 09, 2015 1:25:15 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server number: 7.0.64.0
Oct 09, 2015 1:25:15 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name: Windows 8.1
Oct 09, 2015 1:25:15 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version: 6.3
Oct 09, 2015 1:25:15 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture: amd64
Oct 09, 2015 1:25:15 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Java Home: C:\Program Files\Java\jre7
Oct 09, 2015 1:25:15 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version: 1.7.0_75-b13
Oct 09, 2015 1:25:15 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor: Oracle Corporation
Oct 09, 2015 1:25:15 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE: C:\Users\gafg\Desktop\IVP\.metadata\.plugins\org.eclipse.wst.server.core\tmp1
Oct 09, 2015 1:25:15 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME: C:\Program Files\Apache Software Foundation\Tomcat 7.0
Oct 09, 2015 1:25:15 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=C:\Users\gafg\Desktop\IVP\.metadata\.plugins\org.eclipse.wst.server.core\tmp1
Oct 09, 2015 1:25:15 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=C:\Program Files\Apache Software Foundation\Tomcat 7.0
Oct 09, 2015 1:25:15 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dwtp.deploy=C:\Users\gafg\Desktop\IVP\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps
Oct 09, 2015 1:25:15 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.endorsed.dirs=C:\Program Files\Apache Software Foundation\Tomcat 7.0\endorsed
Oct 09, 2015 1:25:15 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dfile.encoding=Cp1252
Oct 09, 2015 1:25:15 AM 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\Java\jre7\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Program Files/Java/jre7/bin/server;C:/Program Files/Java/jre7/bin;C:/Program Files/Java/jre7/lib/amd64;C:\app\gafg\product\11.2.0\client_1\BIN;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Symantec\VIP Access Client\;C:\Program Files (x86)\Microsoft Team Foundation Server 2013 Power Tools\;C:\Program Files (x86)\Microsoft Team Foundation Server 2013 Power Tools\Best Practices Analyzer\;C:\Microsoft SQL Server Migration Assistant for Oracle\bin\;c:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\;c:\Program Files\Microsoft SQL Server\110\DTS\Binn\;c:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\;c:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\;c:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files (x86)\Skype\Phone\;C:\jdk1.7\bin;.;;C:\Users\gafg\Documents\Eclipse - Kepler\Eclipse-Kepler\eclipse;;.
Oct 09, 2015 1:25:15 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8001"]
Oct 09, 2015 1:25:15 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Oct 09, 2015 1:25:15 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 852 ms
Oct 09, 2015 1:25:15 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Oct 09, 2015 1:25:15 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.64
Oct 09, 2015 1:25:15 AM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(C:\Users\gafg\Desktop\IVP\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\FirstMVCHelloWorld\WEB-INF\lib\javax.servlet-api-3.0.1.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/servlet/Servlet.class
Oct 09, 2015 1:25:16 AM org.apache.catalina.startup.TldConfig execute
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
Oct 09, 2015 1:25:16 AM org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom
INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [111] milliseconds.
Oct 09, 2015 1:25:16 AM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(C:\Users\gafg\Desktop\IVP\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\SimpleWebService\WEB-INF\lib\javax.servlet-api-3.0.1.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/servlet/Servlet.class
Oct 09, 2015 1:25:17 AM org.apache.catalina.startup.TldConfig execute
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
Oct 09, 2015 1:25:18 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8001"]
Oct 09, 2015 1:25:18 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Oct 09, 2015 1:25:18 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 2439 ms
错误是什么?我怎么解决这个问题?
答案 0 :(得分:0)
似乎服务器正常启动。
从项目结构看起来就像你无法编译项目一样:原因是你添加了源文件而不是实际的库。
您可以查看一些已经可用的教程,例如:
如果您仍然遇到任何问题,请粘贴日志文件中的日志条目 你能否从Log4j或slf4j粘贴错误。