SpringRest - 没有为servlet请求找到匹配的处理程序方法

时间:2015-05-16 08:13:53

标签: spring spring-mvc spring-restcontroller

找不到servlet请求的匹配处理程序方法:path' / test / add',方法' POST' ....

 <servlet>
    <servlet-name>dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
    <servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>

配置:

%%%f=figure('name','resize','color','w','windowstyle','modal','numbertitle','off','position',[820 110 500 612],'resize','on')
% Removed "'windowstyle','modal'" to allow debug
f=figure('name','resize','color','w','numbertitle','off', ...
         'position',[820 110 500 612],'resize','on')

hx=axes('Units','inches');

hax = imread('c.jpg');
imshow('c.jpg')
sli=uicontrol('Style','slider',...
    'Min',1,'Max',4,'Value',2,...
    'Position',[50 525 400 20],...
    'Callback', {@resiz,hax})

y=getappdata(0,'x');

uicontrol('Style','text',...
    'Position',[50 555 400 20],...
    'String','Resize');

uicontrol('Style','pushbutton',...
    'Position',[30 565 100 40],...
    'String','Save','Callback',{@save,y});
uicontrol('Style','pushbutton',...
    'Position',[200 565 100 40],...
    'String','Cancel','Callback',@cancel);

任何建议?

2 个答案:

答案 0 :(得分:1)

在web.xml中更改您的调度程序servlet映射,如下所示:

<servlet>
    <servlet-name>dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
    <servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

答案 1 :(得分:1)

也许是因为你的POST请求不是一种&#34; application / json&#34;

注意您的要求/