0

我收到“此请求标识的资源只能生成具有根据请求“接受”标头不可接受的特征的响应。” (http 状态 406)尝试从 url 获取 item_id 参数时出错,如下所示:

http://localhost:8080/products/edit_item.html?item_id=3

然后我将获取 item_id 并从数据库中获取单个项目数据。我正在使用 Spring 3.2.4 Tomcat 7 和 eclipse 开普勒。我的控制器方法是:

@RequestMapping(value="edit_item",method=RequestMethod.GET, params="item_id")
public @ResponseBody ModelAndView editItem(@RequestParam(value="item_id") int item_id)
{
    //do things with item_id
}

我在网上搜索并看到了有关 json 的问题。我的问题很简单,我只需要从 url 获取单个值。我是春天的新手,也许这对你来说很容易,但我做不到。

而配置文件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:p="http://www.springframework.org/schema/p"
    xmlns:context="http://www.springframework.org/schema/context"
    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">
 <import resource="./Ekle/Beans.xml" />
    <context:component-scan
        base-package="Ekle" />


    <bean id="viewResolver"
        class="org.springframework.web.servlet.view.UrlBasedViewResolver">
        <property name="viewClass"
            value="org.springframework.web.servlet.view.JstlView" />
        <property name="prefix" value="/WEB-INF/Ekle/" />
        <property name="suffix" value=".jsp" />
    </bean>
</beans>

这是我的堆栈跟踪:

 Sep 22, 2013 10:31:59 AM org.apache.catalina.core.AprLifecycleListener init
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\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\AMD APP\bin\x86_64;C:\Program Files (x86)\AMD APP\bin\x86;C:\Program Files\Broadcom\Broadcom 802.11 Network Adapter\Driver;;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\Windows Live\Shared;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\apache-maven-3.1.0\bin;C:\Program Files\Java\jdk1.7.0_17\bin;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\apache-maven-3.1.0\bin;C:\Program Files\Java\jdk1.7.0_17\bin;.
Sep 22, 2013 10:31:59 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:DomainYonetim' did not find a matching property.
Sep 22, 2013 10:31:59 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Sep 22, 2013 10:31:59 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Sep 22, 2013 10:31:59 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 747 ms
Sep 22, 2013 10:31:59 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Sep 22, 2013 10:31:59 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.42
Sep 22, 2013 10:32:02 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/core_rt is already defined
Sep 22, 2013 10:32:02 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/core is already defined
Sep 22, 2013 10:32:02 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/core is already defined
Sep 22, 2013 10:32:02 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/fmt_rt is already defined
Sep 22, 2013 10:32:02 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/fmt is already defined
Sep 22, 2013 10:32:02 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/fmt is already defined
Sep 22, 2013 10:32:02 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/functions is already defined
Sep 22, 2013 10:32:02 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://jakarta.apache.org/taglibs/standard/permittedTaglibs is already defined
Sep 22, 2013 10:32:02 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://jakarta.apache.org/taglibs/standard/scriptfree is already defined
Sep 22, 2013 10:32:02 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/sql_rt is already defined
Sep 22, 2013 10:32:02 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/sql is already defined
Sep 22, 2013 10:32:02 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/sql is already defined
Sep 22, 2013 10:32:02 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/xml_rt is already defined
Sep 22, 2013 10:32:02 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/xml is already defined
Sep 22, 2013 10:32:02 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/xml is already defined
Sep 22, 2013 10:32:02 AM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Sep 22, 2013 10:32:02 AM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'spring'
Sep 22, 2013 10:32:02 AM org.springframework.web.servlet.DispatcherServlet initServletBean
INFO: FrameworkServlet 'spring': initialization started
Sep 22, 2013 10:32:02 AM org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh
INFO: Refreshing WebApplicationContext for namespace 'spring-servlet': startup date [Sun Sep 22 10:32:02 PDT 2013]; root of context hierarchy
Sep 22, 2013 10:32:02 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/spring-servlet.xml]
Sep 22, 2013 10:32:02 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/Ekle/Beans.xml]
Sep 22, 2013 10:32:02 AM org.springframework.jdbc.datasource.DriverManagerDataSource setDriverClassName
INFO: Loaded JDBC driver: com.mysql.jdbc.Driver
Sep 22, 2013 10:32:03 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler
INFO: Mapped URL path [/DomainEkle] onto handler 'domainEkleController'
Sep 22, 2013 10:32:03 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler
INFO: Mapped URL path [/DomainEkle.*] onto handler 'domainEkleController'
Sep 22, 2013 10:32:03 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler
INFO: Mapped URL path [/DomainEkle/] onto handler 'domainEkleController'
Sep 22, 2013 10:32:03 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler
INFO: Mapped URL path [/domain_list] onto handler 'domainEkleController'
Sep 22, 2013 10:32:03 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler
INFO: Mapped URL path [/domain_list.*] onto handler 'domainEkleController'
Sep 22, 2013 10:32:03 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler
INFO: Mapped URL path [/domain_list/] onto handler 'domainEkleController'
Sep 22, 2013 10:32:03 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler
INFO: Mapped URL path [/memur_ekle] onto handler 'memurController'
Sep 22, 2013 10:32:03 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler
INFO: Mapped URL path [/memur_ekle.*] onto handler 'memurController'
Sep 22, 2013 10:32:03 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler
INFO: Mapped URL path [/memur_ekle/] onto handler 'memurController'
Sep 22, 2013 10:32:03 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler
INFO: Mapped URL path [/memur_list] onto handler 'memurController'
Sep 22, 2013 10:32:03 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler
INFO: Mapped URL path [/memur_list.*] onto handler 'memurController'
Sep 22, 2013 10:32:03 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler
INFO: Mapped URL path [/memur_list/] onto handler 'memurController'
Sep 22, 2013 10:32:03 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler
INFO: Mapped URL path [/sunucu_ekle] onto handler 'sunucuKontroller'
Sep 22, 2013 10:32:03 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler
INFO: Mapped URL path [/sunucu_ekle.*] onto handler 'sunucuKontroller'
Sep 22, 2013 10:32:03 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler
INFO: Mapped URL path [/sunucu_ekle/] onto handler 'sunucuKontroller'
Sep 22, 2013 10:32:03 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler
INFO: Mapped URL path [/sunucu_list] onto handler 'sunucuKontroller'
Sep 22, 2013 10:32:03 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler
INFO: Mapped URL path [/sunucu_list.*] onto handler 'sunucuKontroller'
Sep 22, 2013 10:32:03 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler
INFO: Mapped URL path [/sunucu_list/] onto handler 'sunucuKontroller'
Sep 22, 2013 10:32:03 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler
INFO: Mapped URL path [/sunucu_duzenle] onto handler 'sunucuKontroller'
Sep 22, 2013 10:32:03 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler
INFO: Mapped URL path [/sunucu_duzenle.*] onto handler 'sunucuKontroller'
Sep 22, 2013 10:32:03 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler
INFO: Mapped URL path [/sunucu_duzenle/] onto handler 'sunucuKontroller'
Sep 22, 2013 10:32:03 AM org.springframework.web.servlet.DispatcherServlet initServletBean
INFO: FrameworkServlet 'spring': initialization completed in 1088 ms
Sep 22, 2013 10:32:03 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Sep 22, 2013 10:32:03 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Sep 22, 2013 10:32:03 AM org.apache.catalina.startup.Catalina start
4

0 回答 0