Spring RequestMapping错误:服务器的响应状态为404(未找到)
Spring RequestMapping error: the server responded with a status of 404 (Not Found)
我对Spring有问题,我需要在执行ajax调用时调用一个方法,但每次尝试调用时,我都会遇到相同的错误:
http://localhost:8080/portaleConservazione/service/rest/enti/management Failed to load resource: the server responded with a status of 404 (Not Found)
这里是我的代码:Java:
@RestController
public class RestGestioneEnti extends RestApiBaseController {
@Autowired
private GenericDao genericDao;
@RequestMapping(value = "/enti/management", method = RequestMethod.POST)
public String handleFormUpload(@RequestParam("token") String token,
@RequestParam("id") int idEnte,
@RequestParam("action") String action,
@RequestParam("entetype") int enteType,
@RequestParam("ipa") String codiceIpaEnte,
@RequestParam("localita") String localita,
@RequestParam("ente_terze_tipo") String enteTerzeTipo,
@RequestParam("ente_terze_bool") String gesinf,
@RequestParam("presa_in_carico") String presaInCarico,
@RequestParam("ragionesociale") String ragioneSociale,
@RequestParam("indirizzo") String indirizzo,
@RequestParam("cap") String cap,
@RequestParam("comune") String comune,
@RequestParam("piva") String partitaIva,
@RequestParam("codiceipa") String codiceIpaMacroEnte,
@RequestParam("path_fattura") String pathContabilitaFattura,
@RequestParam("url_conservazione") String urlConservazione,
@RequestParam("in_modifica") String inModificaString,
@RequestParam("idFatt") String idFattura,
@RequestParam("macro") String macro,
@RequestParam("idAmm") String idAmm,
@RequestParam("idUtente") String idUtente,
@RequestParam("nomemacroente") String nomeMacroEnte,
@RequestParam("idPadre") String idPadre,
@RequestParam("nomeSer") String nomeSer,
@RequestParam("prot_auto_bool") String extProt,
@RequestParam("logo_ente") MultipartFile file) {
Javascript:
$.ajax({
type : "POST",
url : '../service/rest/enti/management',
contentType : 'application/json; charset=utf-8',
data : {"id" : idEnte, "action" : action, "token" : token},
success : function(obj, textstatus) {
obj = obj.trim();
var json = JSON.parse(obj);
if (obj.stato == 'error') {
alert('Errore');
} else {
$(json.data).each(function() {
$(idSelectServizio).append($('<option>', {
value : this.idente,
text : this.ragionesociale,
data : {
idamm : this.idamm
}
}));
});
if ($(json.data).length > 0) {
$('#ricercaConFiltroIdAmmNonCongruo').show();
} else {
$('#ricercaConFiltroIdAmmNonCongruo').hide();
}
}
},
error : function(obj, textstatus) {
alert('Errore di comunicazione col server!');
}
});
Spring调度程序servlet:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:oxm="http://www.springframework.org/schema/oxm" xmlns:util="http://www.springframework.org/schema/util"
xmlns:task="http://www.springframework.org/schema/task" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">
<context:component-scan base-package="it.unimaticaspa.spring" />
<context:annotation-config />
<mvc:annotation-driven />
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/spring-views/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<!-- one of the properties available; the maximum file size in bytes -->
<property name="maxUploadSize" value="30000000" />
</bean>
<!-- <bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource"
destroy-method="close"> <property name="driverClassName" value="${jdbc.driverClassName}"
/> <property name="url" value="${jdbc.url}" /> <property name="username"
value="${jdbc.username}" /> <property name="password" value="${jdbc.password}"
/> </bean> -->
<!-- bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jdbc/portale_pa" /> </bean -->
<jee:jndi-lookup id="dataSource" jndi-name="jdbc/portale_pa"
resource-ref="true" />
<context:property-placeholder location="classpath:jdbc.properties" />
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="it.unimaticaspa.spring.hibernate.model" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
</props>
</property>
</bean>
<tx:annotation-driven />
<!-- gestione transazioni -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="persistenceExceptionTranslationPostProcessor"
class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" />
<!-- gestione dei task tramite annotation -->
<task:scheduler id="taskScheduler" />
<task:executor id="taskExecutor" pool-size="2" />
<task:annotation-driven executor="taskExecutor"
scheduler="taskScheduler" />
<bean id="uninotificheServiceBeanServiceStub"
class="it.unimaticaspa.spring.axis.factory.UninotificheServiceBeanServiceStubFactoryBean"
scope="singleton">
<!-- this next element effects the proxying of the surrounding bean, needed
because .... will try to set the stub out of request scope -->
<aop:scoped-proxy />
<constructor-arg index="0">
<!-- The WS stub is created here, and passed to the factory-method of
... as a parameter -->
<bean
class="it.unimaticaspa.spring.externalservice.uninotifica.stub.UninotificheServiceBeanServiceStub"
scope="prototype">
<constructor-arg ref="axisConfigContext" />
</bean>
</constructor-arg>
</bean>
<bean id="gestioneBlocchiWebServiceBeanServiceStub"
class="it.unimaticaspa.spring.axis.factory.GestioneBlocchiWebServiceBeanServiceStubFactoryBean"
scope="singleton">
<!-- this next element effects the proxying of the surrounding bean, needed
because .... will try to set the stub out of request scope -->
<aop:scoped-proxy />
<constructor-arg index="0">
<!-- The WS stub is created here, and passed to the factory-method of
... as a parameter -->
<bean
class="it.unimaticaspa.spring.service.provaconservazione.wsstub.GestioneBlocchiWebServiceBeanServiceStub"
scope="prototype">
<constructor-arg ref="axisConfigContext" />
</bean>
</constructor-arg>
</bean>
<!-- Exists to avoid deployment of axis jar into temp dir for each request.
See AXIS2-3919 for more details. -->
<bean id="axisConfigContext" class="org.apache.axis2.context.ConfigurationContextFactory"
factory-method="createConfigurationContextFromFileSystem">
<constructor-arg index="0">
<null />
</constructor-arg>
<constructor-arg index="1">
<null />
</constructor-arg>
</bean>
有人能帮我吗?
我解决了以这种方式更改函数参数的问题
Java:
@RequestMapping(value = "enti/management", method = RequestMethod.POST)
public String manageEntiRicerca(@RequestBody String payload) throws Exception {
JSONObject json = new JSONObject(payload);
Javascript:
var payload = {
"idFatt" : idFattura,
"action" : action,
"token" : token
};
var fat = idFattura;
$.ajax({
type : "POST",
url : '../service/rest/enti/management,
contentType : 'application/json; charset=utf-8',
data : JSON.stringify(payload),
resourceType : 'json',
success : function(obj, textstatus) {
obj = obj.trim();
var json = JSON.parse(obj);
// parse response
var res = json.useExtProt;
action_accept_api(fat, res);
},
error : function(request, status, error) {
alert('errore');
}
});
现在工作正常
相关文章:
- 相位器状态未捕获参考错误
- 未捕获的类型错误:无法读取属性'状态'在react中为null
- 使用Twitter API进行推文时出现重复状态错误
- Angularjs$状态错误
- 历史.推送状态错误,我不知道为什么
- indexeddb 调用堆栈的无效状态错误
- YDN:Firefox 版本 44 上出现消息无效状态错误的错误
- 许多画布对象会导致“无效状态错误:尝试使用不可用或不再可用的对象”
- 在angular js promise中未获取状态错误代码
- 使用Angular.js ui路由器获取状态错误
- 在IE11中设置xmlHttp响应类型为msxml-document会抛出无效状态错误
- Angular状态提供程序抛出的问题无法解决状态错误
- 回发时无效的视图状态错误
- 我如何在React JS中处理状态错误
- 使用FileReader时,chrome浏览器的无效状态错误
- 无法解决ui-route中的状态错误
- 收到非活动状态错误- JQuery
- I'm向节点服务器发送了一个文件,它给了我404状态错误
- 未捕获的无效状态错误:无法在“WebSocket”上执行“发送”:仍处于“正在连接”状态
- 没有例外,但状态错误,而做jquery ajax