2017-09-14 106 views
0

在我的應用程序中,我需要從我的Jsp頁面發送一些字符串數據(電子郵件,名稱,消息)到一個控制器,我將做一些驗證並保存在數據庫中我使用Spring Boot。和jQuery我認爲我們使用AJAX,可以請你給我一個例子,到目前爲止,我試過,但奧斯卡最佳噸工作在控制檯得到了一個404錯誤: 的Controler:如何從jsp頁面發送數據到彈簧控制器使用ajax

package com.eBenamar; 


import java.io.BufferedOutputStream; 
import java.io.File; 
import java.io.FileInputStream; 
import java.io.FileNotFoundException; 
import java.io.FileOutputStream; 
import java.io.IOException; 
import java.io.InputStream; 

import java.sql.Date; 
import java.text.ParseException; 
import java.text.SimpleDateFormat; 

import java.util.ArrayList; 

import java.util.HashSet; 
import java.util.List; 
import java.util.Locale; 
import java.util.Set; 
import java.util.regex.Pattern; 



import javax.servlet.ServletContext; 
import javax.servlet.http.HttpServletRequest; 
import javax.servlet.http.HttpServletResponse; 
import javax.servlet.http.HttpSession; 

import org.apache.commons.io.FileUtils; 
import org.apache.commons.io.IOUtils; 

import org.springframework.beans.factory.annotation.Autowired; 

import org.springframework.data.domain.Page; 
import org.springframework.data.domain.PageRequest; 
import org.springframework.data.domain.Pageable; 
import org.springframework.mail.MailSender; 
import org.springframework.mail.SimpleMailMessage; 
import org.springframework.stereotype.Controller; 
import org.springframework.ui.Model; 
import org.springframework.validation.BindingResult; 
import org.springframework.web.bind.annotation.ModelAttribute; 
import org.springframework.web.bind.annotation.PathVariable; 
import org.springframework.web.bind.annotation.RequestBody; 
import org.springframework.web.bind.annotation.RequestMapping; 
import org.springframework.web.bind.annotation.RequestMethod; 
import org.springframework.web.bind.annotation.RequestParam; 
import org.springframework.web.bind.annotation.ResponseBody; 

import org.springframework.web.multipart.MultipartFile; 
import org.springframework.web.servlet.ModelAndView; 

import com.eBenamar.Dao.AnnonceDao; 
import com.eBenamar.Dao.UserDao; 
import com.eBenamar.Entities.Annonce; 
import com.eBenamar.Entities.AnnonceAuto; 
import com.eBenamar.Entities.Annonceur; 
import com.eBenamar.Entities.Auto; 
import com.eBenamar.Entities.User; 
import com.fasterxml.jackson.databind.ObjectMapper; 
// commentaires 
// controller 
@Controller 
public class AnnonceController { 
    /*@Autowired //zyada 
    private AnnonceAutoDao annonceautodao;*/ 
    /*@Autowired 
    private Annonceur annonceur;*/ 

    private MailSender mailSender; 

    private SimpleMailMessage templateMessage; 

    @Autowired 

     private ServletContext context; 
    private Integer lastid; 
    @Autowired 
    private AnnonceDao annoncedao; 
    @Autowired 
    private UserDao userDao; 
    /*@Autowired //zyada 
    private AutoInterfaceDao autodao;*/ 
    Integer NBPAGE=5; 
    String DESTINATION="e:\\images\\"; 
    String DESTINATION1="e:\\temp\\"; 


@RequestMapping(value="/cherchetitre",method=RequestMethod.POST) 
public String cherchetitre(@RequestParam("recherchetitre") String titre ,Model md 
     ,@RequestParam("adresse") String ville) 
{ 
    System.out.println("/cherchetitre.. post"); 
    PageRequest request = 
      new PageRequest(1,NBPAGE); 
    Page <Annonce> annonces= annoncedao.findByTitreContaining(titre,request); 



    md.addAttribute("annonces",annonces); 
    return "affiche"; 

} 
@RequestMapping(value="/sendemail1",method=RequestMethod.POST) 
    public void sendemail(){ 


    } 
    @RequestMapping(value="/sendemail1",method=RequestMethod.GET) 
    public void sendemailget(){ 

} 

JSP頁面:

<div class="row col-xs-10 col-md-6 form-group"> 
<!--    <textarea rows="5" class="form-control"></textarea> --> 
      <springform:textarea path="message" name="message" class="form-control" rows="5"/> 
      </div> 
      <div class="row"> 
       <span class="col-xs-12 col-md-4"> 
       <a class="btn btn-info navbar-btn navbar-right" id="sendemail">Envoyer email</a> 
       </span> 
      </div> 
<script> 
$('#sendemail').click(function(){ 
    $.ajax({ 
      url:'/sendemail1', 
      type:"Post", 
      dataType:'json', 
      contentType : "application/json; charset=utf-8", 
      success : function() { 
        console.log("SUCCESS: "); 

        }, 
      error : function() { 
        console.log("ERROR: "); 

        }, 
      done : function() { 
        console.log("DONE"); 

        } 
    }); 

}); 
</script> 

錯誤控制檯:

Request URL:http://localhost:8989/sendemail 
Request Method:POST 
Status Code:404 
Remote Address:[::1]:8989 
Referrer Policy:no-referrer-when-downgrade 
Response Headers 
view source 
Content-Language:fr-FR 
Content-Type:application/json;charset=UTF-8 
Date:Thu, 14 Sep 2017 04:33:30 GMT 
Transfer-Encoding:chunked 
Request Headers 
view source 
Accept:application/json, text/javascript, */*; q=0.01 
Accept-Encoding:gzip, deflate, br 
Accept-Language:fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4 
Connection:keep-alive 
Content-Length:0 
Content-Type:application/json; charset=utf-8 
Cookie:JSESSIONID=B40E408BBC4209D1CECC9336B3AD3EC1 
Host:localhost:8989 
Origin:http://localhost:8989 
Referer:http://localhost:8989/detail/1 
User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36 
X-Requested-With:XMLHttpRequest 

啓動日誌:

. ____   _   __ _ _ 
/\\/___'_ __ _ _(_)_ __ __ _ \ \ \ \ 
(()\___ | '_ | '_| | '_ \/ _` | \ \ \ \ 
\\/ ___)| |_)| | | | | || (_| | )))) 
    ' |____| .__|_| |_|_| |_\__, |//// 
=========|_|==============|___/=/_/_/_/ 
:: Spring Boot ::  (v1.4.1.RELEASE) 

2017-09-14 12:48:56.283 INFO 12980 --- [   main] com.eBenamar.Kijiji2Application   : Starting Kijiji2Application on DESKTOP-DRHD9PN with PID 12980 (C:\Users\user\workspace\kijiji2\target\classes started by user in C:\Users\user\workspace\kijiji2) 
2017-09-14 12:48:56.288 INFO 12980 --- [   main] com.eBenamar.Kijiji2Application   : No active profile set, falling back to default profiles: default 
2017-09-14 12:48:56.507 INFO 12980 --- [   main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot[email protected]5f058f00: startup date [Thu Sep 14 12:48:56 EDT 2017]; root of context hierarchy 
2017-09-14 12:49:00.407 INFO 12980 --- [   main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$289fc04d] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 
2017-09-14 12:49:01.713 INFO 12980 --- [   main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8989 (http) 
2017-09-14 12:49:01.745 INFO 12980 --- [   main] o.apache.catalina.core.StandardService : Starting service Tomcat 
2017-09-14 12:49:01.748 INFO 12980 --- [   main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.5 
2017-09-14 12:49:02.631 INFO 12980 --- [ost-startStop-1] org.apache.jasper.servlet.TldScanner  : At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. 
2017-09-14 12:49:02.640 INFO 12980 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]  : Initializing Spring embedded WebApplicationContext 
2017-09-14 12:49:02.641 INFO 12980 --- [ost-startStop-1] o.s.web.context.ContextLoader   : Root WebApplicationContext: initialization completed in 6139 ms 
2017-09-14 12:49:03.193 INFO 12980 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/] 
2017-09-14 12:49:03.198 INFO 12980 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*] 
2017-09-14 12:49:03.199 INFO 12980 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*] 
2017-09-14 12:49:03.199 INFO 12980 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*] 
2017-09-14 12:49:03.199 INFO 12980 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*] 
2017-09-14 12:49:03.886 INFO 12980 --- [   main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default' 
2017-09-14 12:49:03.919 INFO 12980 --- [   main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [ 
    name: default 
    ...] 
2017-09-14 12:49:04.093 INFO 12980 --- [   main] org.hibernate.Version     : HHH000412: Hibernate Core {5.0.11.Final} 
2017-09-14 12:49:04.095 INFO 12980 --- [   main] org.hibernate.cfg.Environment   : HHH000206: hibernate.properties not found 
2017-09-14 12:49:04.101 INFO 12980 --- [   main] org.hibernate.cfg.Environment   : HHH000021: Bytecode provider name : javassist 
2017-09-14 12:49:04.185 INFO 12980 --- [   main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final} 
Thu Sep 14 12:49:04 EDT 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification. 
Thu Sep 14 12:49:05 EDT 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification. 
Thu Sep 14 12:49:05 EDT 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification. 
Thu Sep 14 12:49:05 EDT 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification. 
Thu Sep 14 12:49:05 EDT 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification. 
Thu Sep 14 12:49:05 EDT 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification. 
Thu Sep 14 12:49:05 EDT 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification. 
Thu Sep 14 12:49:05 EDT 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification. 
Thu Sep 14 12:49:05 EDT 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification. 
Thu Sep 14 12:49:05 EDT 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification. 
2017-09-14 12:49:05.342 INFO 12980 --- [   main] org.hibernate.dialect.Dialect   : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect 
2017-09-14 12:49:06.544 INFO 12980 --- [   main] org.hibernate.tool.hbm2ddl.SchemaUpdate : HHH000228: Running hbm2ddl schema update 
2017-09-14 12:49:07.151 INFO 12980 --- [   main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default' 
2017-09-14 12:49:07.784 INFO 12980 --- [   main] o.h.h.i.QueryTranslatorFactoryInitiator : HHH000397: Using ASTQueryTranslatorFactory 
2017-09-14 12:49:08.825 INFO 12980 --- [   main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot[email protected]5f058f00: startup date [Thu Sep 14 12:48:56 EDT 2017]; root of context hierarchy 
2017-09-14 12:49:09.031 INFO 12980 --- [   main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/home]}" onto public java.lang.String com.eBenamar.AnnonceController.index() 
2017-09-14 12:49:09.033 INFO 12980 --- [   main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/save],methods=[POST]}" onto public java.lang.String com.eBenamar.AnnonceController.add(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,org.springframework.web.multipart.MultipartFile,org.springframework.web.multipart.MultipartFile,org.springframework.web.multipart.MultipartFile,org.springframework.web.multipart.MultipartFile,org.springframework.web.multipart.MultipartFile,org.springframework.web.multipart.MultipartFile,org.springframework.web.multipart.MultipartFile,org.springframework.web.multipart.MultipartFile,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,org.springframework.ui.Model,javax.servlet.http.HttpSession) throws java.io.FileNotFoundException 
2017-09-14 12:49:09.034 INFO 12980 --- [   main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/test1]}" onto public java.lang.String com.eBenamar.AnnonceController.test(org.springframework.ui.Model) 
2017-09-14 12:49:09.034 INFO 12980 --- [   main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/detail/{id}]}" onto public java.lang.String com.eBenamar.AnnonceController.detail(org.springframework.ui.Model,java.lang.Integer,javax.servlet.http.HttpServletResponse) throws java.text.ParseException,java.io.IOException 
2017-09-14 12:49:09.034 INFO 12980 --- [   main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/affiche]}" onto public java.lang.String com.eBenamar.AnnonceController.affiche2(org.springframework.ui.Model,java.lang.String,java.lang.String,java.lang.String) 
2017-09-14 12:49:09.034 INFO 12980 --- [   main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/save],methods=[GET]}" onto public java.lang.String com.eBenamar.AnnonceController.addget(com.eBenamar.Entities.AnnonceAuto,org.springframework.validation.BindingResult,javax.servlet.http.HttpSession) 
2017-09-14 12:49:09.035 INFO 12980 --- [   main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/imagetemp3],methods=[GET]}" onto public void com.eBenamar.AnnonceController.affichimagetemp3(org.springframework.ui.Model,javax.servlet.http.HttpSession,javax.servlet.http.HttpServletResponse,javax.servlet.http.HttpServletRequest) throws java.io.IOException,java.lang.NullPointerException 
2017-09-14 12:49:09.036 INFO 12980 --- [   main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/imagetemp6],methods=[GET]}" onto public void com.eBenamar.AnnonceController.affichimagetemp6(org.springframework.ui.Model,javax.servlet.http.HttpSession,javax.servlet.http.HttpServletResponse,javax.servlet.http.HttpServletRequest) throws java.io.IOException,java.lang.NullPointerException 
2017-09-14 12:49:09.037 INFO 12980 --- [   main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/affiche///{pagenumber}],methods=[GET]}" onto public java.lang.String com.eBenamar.AnnonceController.affiche1(java.lang.Integer,org.springframework.ui.Model) 
2017-09-14 12:49:09.038 INFO 12980 --- [   main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/images],methods=[GET]}" onto public void com.eBenamar.AnnonceController.affichimage(java.lang.Integer,javax.servlet.http.HttpServletResponse,javax.servlet.http.HttpServletRequest) throws java.io.IOException,java.lang.NullPointerException 
2017-09-14 12:49:09.039 INFO 12980 --- [   main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/images5],methods=[GET]}" onto public void com.eBenamar.AnnonceController.affichimage5(java.lang.Integer,javax.servlet.http.HttpServletResponse,javax.servlet.http.HttpServletRequest) throws java.io.IOException,java.lang.NullPointerException 
2017-09-14 12:49:09.042 INFO 12980 --- [   main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/imagetemp4],methods=[GET]}" onto public void com.eBenamar.AnnonceController.affichimagetemp4(org.springframework.ui.Model,javax.servlet.http.HttpSession,javax.servlet.http.HttpServletResponse,javax.servlet.http.HttpServletRequest) throws java.io.IOException,java.lang.NullPointerException 
2017-09-14 12:49:09.042 INFO 12980 --- [   main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/imagetemp5],methods=[GET]}" onto public void com.eBenamar.AnnonceController.affichimagetemp5(org.springframework.ui.Model,javax.servlet.http.HttpSession,javax.servlet.http.HttpServletResponse,javax.servlet.http.HttpServletRequest) throws java.io.IOException,java.lang.NullPointerException 
2017-09-14 12:49:09.043 INFO 12980 --- [   main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/images7],methods=[GET]}" onto public void com.eBenamar.AnnonceController.affichimage7(java.lang.Integer,javax.servlet.http.HttpServletResponse,javax.servlet.http.HttpServletRequest) throws java.io.IOException,java.lang.NullPointerException 
2017-09-14 12:49:09.043 INFO 12980 --- [   main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/imagetemp7],methods=[GET]}" onto public void com.eBenamar.AnnonceController.affichimagetemp7(org.springframework.ui.Model,javax.servlet.http.HttpSession,javax.servlet.http.HttpServletResponse,javax.servlet.http.HttpServletRequest) throws java.io.IOException,java.lang.NullPointerException 
2017-09-14 12:49:09.043 INFO 12980 --- [   main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/imagetemp8],methods=[GET]}" onto public void com.eBenamar.AnnonceController.affichimagetemp8(org.springframework.ui.Model,javax.servlet.http.HttpSession,javax.servlet.http.HttpServletResponse,javax.servlet.http.HttpServletRequest) throws java.io.IOException,java.lang.NullPointerException 
2017-09-14 12:49:09.044 INFO 12980 --- [   main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/images6],methods=[GET]}" onto public void com.eBenamar.AnnonceController.affichimage6(java.lang.Integer,javax.servlet.http.HttpServletResponse,javax.servlet.http.HttpServletRequest) throws java.io.IOException,java.lang.NullPointerException 
2017-09-14 12:49:09.044 INFO 12980 --- [   main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/images2],methods=[GET]}" onto public void com.eBenamar.AnnonceController.affichimage2(java.lang.Integer,javax.servlet.http.HttpServletResponse,javax.servlet.http.HttpServletRequest) throws java.io.IOException,java.lang.NullPointerException 
2017-09-14 12:49:09.044 INFO 12980 --- [   main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/imagetemp2],methods=[GET]}" onto public void com.eBenamar.AnnonceController.affichimagetemp2(org.springframework.ui.Model,javax.servlet.http.HttpSession,javax.servlet.http.HttpServletResponse,javax.servlet.http.HttpServletRequest) throws java.io.IOException,java.lang.NullPointerException 
2017-09-14 12:49:09.045 INFO 12980 --- [   main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/imagetemp],methods=[GET]}" onto public void com.eBenamar.AnnonceController.affichimagetemp(org.springframework.ui.Model,javax.servlet.http.HttpSession,javax.servlet.http.HttpServletResponse,javax.servlet.http.HttpServletRequest) throws java.io.IOException,java.lang.NullPointerException 
2017-09-14 12:49:09.053 INFO 12980 --- [   main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/images8],methods=[GET]}" onto public void com.eBenamar.AnnonceController.affichimage8(java.lang.Integer,javax.servlet.http.HttpServletResponse,javax.servlet.http.HttpServletRequest) throws java.io.IOException,java.lang.NullPointerException 
2017-09-14 12:49:09.053 INFO 12980 --- [   main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/images3],methods=[GET]}" onto public void com.eBenamar.AnnonceController.affichimage3(java.lang.Integer,javax.servlet.http.HttpServletResponse,javax.servlet.http.HttpServletRequest) throws java.io.IOException,java.lang.NullPointerException 
2017-09-14 12:49:09.054 INFO 12980 --- [   main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/images4],methods=[GET]}" onto public void com.eBenamar.AnnonceController.affichimage4(java.lang.Integer,javax.servlet.http.HttpServletResponse,javax.servlet.http.HttpServletRequest) throws java.io.IOException,java.lang.NullPointerException 
2017-09-14 12:49:09.054 INFO 12980 --- [   main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/cherchetitre],methods=[POST]}" onto public java.lang.String com.eBenamar.AnnonceController.cherchetitre(java.lang.String,org.springframework.ui.Model,java.lang.String) 
2017-09-14 12:49:09.054 INFO 12980 --- [   main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/affiche//{selectedcategorie}/{ville}/{pagenumber}],methods=[GET]}" onto public java.lang.String com.eBenamar.AnnonceController.affiche(java.lang.Integer,org.springframework.ui.Model,java.lang.String,java.lang.String) 
2017-09-14 12:49:09.054 INFO 12980 --- [   main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/affiche/{ville}],methods=[POST]}" onto public java.lang.String com.eBenamar.AnnonceController.affiche(org.springframework.ui.Model,java.lang.String,java.lang.String) 
2017-09-14 12:49:09.061 INFO 12980 --- [   main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/affiche/{search}/{selectedcategorie}/{ville}/{pagenumber}],methods=[GET]}" onto public java.lang.String com.eBenamar.AnnonceController.affiche(java.lang.Integer,java.lang.String,org.springframework.ui.Model,java.lang.String,java.lang.String) 
2017-09-14 12:49:09.061 INFO 12980 --- [   main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/sendemail1],methods=[GET]}" onto public java.lang.String com.eBenamar.AnnonceController.sendemailget() 
2017-09-14 12:49:09.062 INFO 12980 --- [   main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/sendemail1],methods=[POST]}" onto public java.lang.String com.eBenamar.AnnonceController.sendemail(com.eBenamar.Entities.Annonceur) 
2017-09-14 12:49:09.063 INFO 12980 --- [   main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/test/{nb}],methods=[GET]}" onto public org.springframework.web.servlet.ModelAndView com.eBenamar.AnnonceController.test1(java.lang.Integer) 
2017-09-14 12:49:09.068 INFO 12980 --- [   main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest) 
2017-09-14 12:49:09.068 INFO 12980 --- [   main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) 
2017-09-14 12:49:09.267 INFO 12980 --- [   main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 
2017-09-14 12:49:09.269 INFO 12980 --- [   main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 
2017-09-14 12:49:09.374 INFO 12980 --- [   main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 
2017-09-14 12:49:10.224 INFO 12980 --- [   main] o.s.j.e.a.AnnotationMBeanExporter  : Registering beans for JMX exposure on startup 
2017-09-14 12:49:10.403 INFO 12980 --- [   main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8989 (http) 
2017-09-14 12:49:10.411 INFO 12980 --- [   main] com.eBenamar.Kijiji2Application   : Started Kijiji2Application in 15.107 seconds (JVM running for 15.917) 
2017-09-14 12:49:17.787 INFO 12980 --- [nio-8989-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]  : Initializing Spring FrameworkServlet 'dispatcherServlet' 
2017-09-14 12:49:17.788 INFO 12980 --- [nio-8989-exec-1] o.s.web.servlet.DispatcherServlet  : FrameworkServlet 'dispatcherServlet': initialization started 
2017-09-14 12:49:17.833 INFO 12980 --- [nio-8989-exec-1] o.s.web.servlet.DispatcherServlet  : FrameworkServlet 'dispatcherServlet': initialization completed in 45 ms 
+0

請添加整個控制器代碼。此外,啓動日誌可能會有所幫助 –

+0

我更新了整個控制器和啓動日誌,謝謝。 –

回答

0

請。提供你的配置。有一些奇怪的東西。查看啓動日誌:

2017-09-14 12:49:09.061 INFO 12980 --- [   main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/sendemail1],methods=[GET]}" onto public java.lang.String com.eBenamar.AnnonceController.sendemailget() 
2017-09-14 12:49:09.062 INFO 12980 --- [   main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/sendemail1],methods=[POST]}" onto public java.lang.String com.eBenamar.AnnonceController.sendemail(com.eBenamar.Entities.Annonceur) 

您有/sendemail1端點。另外,其他端點還有其他奇怪的數字。有錯誤的映射問題不等於您的代碼

+0

對不起,因爲我將sendemail更改爲sendemail1但未更新。實際上它應該是sendemail1的映射和腳本。我更新 –

+0

好吧,你可以嘗試將'@ Controller'註釋改爲'@ RestController'嗎? –

相關問題