1
我遇到了Spring問題,我需要在執行ajax調用時調用某個方法,但每次我嘗試調用時,都有總是相同的錯誤:Spring RequestMapping錯誤:服務器響應狀態爲404(未找到)
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!');
}
});
春季調度員的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>
有人能幫助我嗎?
請提供春季調度配置servlet – Vladimir
@Vladimir我編輯了主帖 –
不確定,但您的handleFormUpload除了27個參數,但您的數據只給出3個參數。你確定這可以工作嗎? –