Spring mvc 404在Spring2,5中找不到资源使用multiactioncontroller时出错
所有的配置在代码中都是最正确的,但资源的错误放置仍在继续 从“simple.jsp”请求/student3.htm被发送到“web.xml”和“spring servlet.xml”到SimpleUrlHandlerMapping请求/student3.htm被映射为bean id=class3,它进入具有methodNameParameter has属性的multiactioncontroller 它连接到PropertiesMethodNameResolver类,其属性为“mappings”,将请求/student3.htm映射到multiactioncontroller扩展类中的“save”命名方法,即“Multi.java”类。 然后save方法通过/WEB-INF/jsp/multi.jsp中的InternalResourceViewResolver将ModelAndView作为multi.jsp的视图名称“multi”返回给消息multiactionsuccessSpring mvc 404在Spring2,5中找不到资源使用multiactioncontroller时出错,spring-mvc,Spring Mvc,所有的配置在代码中都是最正确的,但资源的错误放置仍在继续 从“simple.jsp”请求/student3.htm被发送到“web.xml”和“spring servlet.xml”到SimpleUrlHandlerMapping请求/student3.htm被映射为bean id=class3,它进入具有methodNameParameter has属性的multiactioncontroller 它连接到PropertiesMethodNameResolver类,其属性为“mappings”
HTTP Status 404 - /student3.htm
--------------------------------------------------------------------------------
type Status report
message /student3.htm
description The requested resource (/student3.htm) is not available.
--------------------------------------------------------------------------------
Apache Tomcat/6.0.35
In console
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_12\bin;.;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files (x86)\Java\jdk1.6.0_12\bin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:springmvc2.56' did not find a matching property.
no error message is found and only warning message.please found out the 404 error found in Broswer.
In 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_2_5.xsd" id="WebApp_ID" version="2.5">
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
</web-app>
in spring-servlet.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:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd">
<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<value>
/student3.htm=class3
/student4.htm=class3
/student5.htm=class3
/student6.htm=class3
</value>
</property>
</bean>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" >
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<property name="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".jsp"/>
</bean>
<bean id="class3" class="com.spring.controller.Multi">
<property name="methodNameResolver" >
<bean class="org.springframework.web.servlet.mvc.multiaction.PropertiesMethodNameResolver">
<property name="mappings" >
<value>
/student3.htm=save
/student4.htm=update
/student5.htm=delete
/student6.htm=select
</value>
</property>
</bean>
</property>
</bean>
</beans>
In WebContent simple.jsp
<%@taglib prefix="c" uri="http://www.springframework.org/tags" %>
<%@taglib prefix="f" uri="http://www.springframework.org/tags/form" %>
<a href="/student3.htm" >save</a>
<a href="/student4.htm" >update</a>
<a href="/student5.htm" >delete</a>
<a href="/student6.htm" >select</a>
In com.spring.controller package Multi.java is controller Class
package com.spring.controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;
public class Multi extends MultiActionController
{
protected ModelAndView save(HttpServletRequest arg0,
HttpServletResponse arg1) throws Exception
{
ModelAndView mav = new ModelAndView();
mav.setViewName("multi1");
return mav;
}
protected ModelAndView update(HttpServletRequest arg0,
HttpServletResponse arg1) throws Exception
{
ModelAndView mav = new ModelAndView();
mav.setViewName("multi1");
return mav;
}
protected ModelAndView select(HttpServletRequest arg0,
HttpServletResponse arg1) throws Exception
{
ModelAndView mav = new ModelAndView();
mav.setViewName("multi1");
return mav;
}
protected ModelAndView delete(HttpServletRequest arg0,
HttpServletResponse arg1) throws Exception
{
ModelAndView mav = new ModelAndView();
mav.setViewName("multi1");
return mav;
}
}
In WEB-INF/jsp folder "multi.jsp" is present
multiaction success.
HTTP Status 404-/student3.htm
--------------------------------------------------------------------------------
类型状态报告
message/student3.htm
说明请求的资源(/student3.htm)不可用。
--------------------------------------------------------------------------------
ApacheTomcat/6.0.35
控制台中
信息:在java.library.path:C:\Program Files(x86)\java\jdk1.6.0\u 12\bin;上找不到允许在生产环境中实现最佳性能的基于APR的Apache Tomcat本机库;。;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\ProgramFiles(x86)\Java\jdk1.6.0\u 12\bin
警告:[SetPropertiesRule]{Server/Service/Engine/Host/Context}将属性“source”设置为“org.eclipse.jst.jee.Server:springmvc2.56”未找到匹配的属性。
找不到错误消息,只有警告消息。请查找Broswer中的404错误。
在web.xml中
春天
org.springframework.web.servlet.DispatcherServlet
1.
春天
*.htm
在spring-servlet.xml中
/student3.htm=class3
/student4.htm=class3
/student5.htm=class3
/student6.htm=class3
/student3.htm=保存
/student4.htm=更新
/student5.htm=删除
/student6.htm=选择
在WebContent simple.jsp中
在com.spring.controller包中,Multi.java是控制器类
包com.spring.controller;
导入javax.servlet.http.HttpServletRequest;
导入javax.servlet.http.HttpServletResponse;
导入org.springframework.web.servlet.ModelAndView;
导入org.springframework.web.servlet.mvc.multiaction.MultiActionController;
公共类Multi扩展MultiActionController
{
受保护的模型和视图保存(HttpServletRequest arg0,
HttpServletResponse arg1)引发异常
{
ModelAndView mav=新ModelAndView();
mav.setViewName(“multi1”);
返回mav;
}
受保护的模型和视图更新(HttpServletRequest arg0,
HttpServletResponse arg1)引发异常
{
ModelAndView mav=新ModelAndView();
mav.setViewName(“multi1”);
返回mav;
}
受保护的模型和视图选择(HttpServletRequest arg0,
HttpServletResponse arg1)引发异常
{
ModelAndView mav=新ModelAndView();
mav.setViewName(“multi1”);
返回mav;
}
受保护的模型和视图删除(HttpServletRequest arg0,
HttpServletResponse arg1)引发异常
{
ModelAndView mav=新ModelAndView();
mav.setViewName(“multi1”);
返回mav;
}
}
在WEB-INF/jsp文件夹中存在“multi.jsp”
多行动的成功。
方法-access指定用户定义的方法应为“公共”
-返回类型应为“ModelAndView,Map,void”
在上述代码中,重分类是
在WebContent simple.jsp中
在com.spring.controller包中,Multi.java是控制器类
方法访问指定应该是公共的
在所有方法中将multi1更改为multias successView
完成代码编辑后,将成功执行此操作。
请格式化您的问题。这是不可读的。
method - access specifies should be "public" by userdefined methods
-returntype should be "ModelAndView,Map,void"
In the above code retifications are
In WebContent simple.jsp
<a href="student3.htm" >save</a>
<a href="student4.htm" >update</a>
<a href="student5.htm" >delete</a>
<a href="student6.htm" >select</a>
In com.spring.controller package Multi.java is controller Class
method access specifies should be public
change multi1 to multi as successView in all methods
After editing the code done this is successfully executed.