久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<legend id='XJWV0'><style id='XJWV0'><dir id='XJWV0'><q id='XJWV0'></q></dir></style></legend>

<small id='XJWV0'></small><noframes id='XJWV0'>

      <i id='XJWV0'><tr id='XJWV0'><dt id='XJWV0'><q id='XJWV0'><span id='XJWV0'><b id='XJWV0'><form id='XJWV0'><ins id='XJWV0'></ins><ul id='XJWV0'></ul><sub id='XJWV0'></sub></form><legend id='XJWV0'></legend><bdo id='XJWV0'><pre id='XJWV0'><center id='XJWV0'></center></pre></bdo></b><th id='XJWV0'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='XJWV0'><tfoot id='XJWV0'></tfoot><dl id='XJWV0'><fieldset id='XJWV0'></fieldset></dl></div>
        <bdo id='XJWV0'></bdo><ul id='XJWV0'></ul>
    1. <tfoot id='XJWV0'></tfoot>

        java.util.MissingResourceException:找不到基本名稱 java

        java.util.MissingResourceException: Can#39;t find bundle for base name javax.servlet.LocalStrings, locale es_ES(java.util.MissingResourceException:找不到基本名稱 javax.servlet.LocalStrings 的包,區(qū)域設(shè)置 es_ES) - IT屋-程序員軟
        <legend id='1QO8X'><style id='1QO8X'><dir id='1QO8X'><q id='1QO8X'></q></dir></style></legend>

        <tfoot id='1QO8X'></tfoot>

              <bdo id='1QO8X'></bdo><ul id='1QO8X'></ul>

                    <tbody id='1QO8X'></tbody>

                  <small id='1QO8X'></small><noframes id='1QO8X'>

                  <i id='1QO8X'><tr id='1QO8X'><dt id='1QO8X'><q id='1QO8X'><span id='1QO8X'><b id='1QO8X'><form id='1QO8X'><ins id='1QO8X'></ins><ul id='1QO8X'></ul><sub id='1QO8X'></sub></form><legend id='1QO8X'></legend><bdo id='1QO8X'><pre id='1QO8X'><center id='1QO8X'></center></pre></bdo></b><th id='1QO8X'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='1QO8X'><tfoot id='1QO8X'></tfoot><dl id='1QO8X'><fieldset id='1QO8X'></fieldset></dl></div>
                • 本文介紹了java.util.MissingResourceException:找不到基本名稱 javax.servlet.LocalStrings 的包,區(qū)域設(shè)置 es_ES的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  我正在嘗試在我的一個(gè) servlet 中執(zhí)行一些 jUnit 測試,但每當(dāng)我嘗試運(yùn)行它時(shí),我都會(huì)獲得 ExceptionInInitializerError.我讀過這個(gè)錯(cuò)誤是由于一個(gè)異常,在評(píng)估靜態(tài)初始化程序或靜態(tài)變量的初始化程序期間發(fā)生的.問題是,即使我試圖修復(fù)它,我也可以.這就是我在這里寫的原因:我的 servlet 代碼如下:

                  I am trying to perform some jUnit test in one of my servlets but whenever I try to run it I obtain a ExceptionInInitializerError. I've read that this error is due to an exception, occurred during evaluation of a static initializer or the initializer for a static variable. The thing is that even though I tried to fix it I can. That's why I am writing here: my servlet code is the following:

                  public class AppServlet extends HttpServlet {
                  
                  // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
                  /**
                   * Handles the HTTP <code>GET</code> method.
                   *
                   * @param request servlet request
                   * @param response servlet response
                   * @throws ServletException if a servlet-specific error occurs
                   * @throws IOException if an I/O error occurs
                   */
                  @Override
                  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
                      try {
                          response.setContentType("text/html;charset=UTF-8");
                          PrintWriter out = response.getWriter();
                  
                          //obtenemos los valores de los campos del formulario.
                          String usr = request.getParameter("usrName");
                          String cp = request.getParameter("codigoPostal");
                          Gson gson = new Gson();
                          if (usr == null || cp == null || cp.length() != 5) {
                              Result r = new Result("KO", "No se introdujeron bien los datos");
                              String jsonString = gson.toJson(r);
                              out.println(jsonString);
                              return;
                          }
                  
                          //procedemos a convertir el codigo postal en la ciudad usando geonames:
                          //para ello usaremos la api de geonames
                          String city = geoLocalize.localizeCity(cp);
                  
                          //empezaremos con el codigo de depuración para ver donde podemos tener errores
                          if (city == null) {
                              Result r = new Result("KO", "No hay ciudad para dicho codigo postal");
                              String jsonString = gson.toJson(r);
                              out.println(jsonString);
                              return;
                          }
                          //comenzamos con las bases de datos
                          SQLconnection db = new SQLconnection();
                          //una vez creada la conexion deberemos hacer las insert en las tablas.
                  
                          if (!db.checkUsr(usr)) {
                              if (db.insertUsr(usr)) {
                                  int numCp = parseInt(cp);
                                  if (!db.checkCP(numCp)) {
                                      if (db.addCity(numCp, city)) {
                                          Result r = new Result("OK", "Proceso terminado sin problemas");
                                          String jsonString = gson.toJson(r);
                                          out.println(jsonString);
                                          return;
                                      } else {
                                          Result r = new Result("KO", "No se ha podido a?adir la ciudad");
                                          String jsonString = gson.toJson(r);
                                          out.println(jsonString);
                                          return;
                                      }
                  
                                  } else {
                                      Result r = new Result("OK", "Se ha a?adido el usuario, el codigo postal ya estaba");
                                      String jsonString = gson.toJson(r);
                                      out.println(jsonString);
                                      return;
                                  }
                              } else {
                                  Result r = new Result("KO", "No se ha podido a?adir el usuario");
                                  String jsonString = gson.toJson(r);
                                  out.println(jsonString);
                                  return;
                              }
                  
                          } else {
                              Result r = new Result("KO", "El usuario ya existe en el sistema");
                              String jsonString = gson.toJson(r);
                              out.println(jsonString);
                              return;
                          }
                  
                      } catch (IOException | NumberFormatException ex) {
                          Logger.getLogger(AppServlet.class.getName()).log(Level.SEVERE, null, ex);
                      } catch (Exception ex) {
                          Logger.getLogger(AppServlet.class.getName()).log(Level.SEVERE, null, ex);
                      }
                  }
                  

                  }

                  而我的 jUnit 測試代碼如下:

                  And my jUnit test code is the following:

                  public class AppServletTest extends TestCase {
                  
                  HttpServletRequest request;
                  HttpServletResponse response;
                  AppServlet instance;
                  
                  public AppServletTest(String testName) {
                      super(testName);
                  
                  }
                  
                  
                  @Override
                  protected void setUp() throws Exception {
                      request = mock(HttpServletRequest.class);
                      response = mock(HttpServletResponse.class);
                      instance = new AppServlet();
                      super.setUp();
                  }
                  
                  
                  @Override
                  protected void tearDown() throws Exception {
                      super.tearDown();
                  }
                  
                  /**
                   * Test of doGet method, of class AppServlet.
                   *
                   * @throws java.lang.Exception
                   */
                  
                  public void testDoGet() throws Exception {
                      System.out.println("doGet");
                  
                      //generamos los parametros y un .txt donde guardaremos la respuesta JSON
                      when(request.getParameter("usrName")).thenReturn("Javi");
                      when(request.getParameter("codigoPostal")).thenReturn("48991");
                      PrintWriter writer = new PrintWriter("resultadoPruebas.txt");
                      when(response.getWriter()).thenReturn(writer);
                  
                      //mandamos la peticion al servlet
                      instance.doGet(request, response);
                  
                      verify(request, atLeast(1)).getParameter("usrName"); // para verificar si se ha llamado a usrName
                      writer.flush(); // it may not have been flushed yet...
                      assertTrue(FileUtils.fileRead(new File("somefile.txt"), "UTF-8")
                              .contains("OK"));
                  
                  
                  }
                  

                  }

                  這里是完整的堆棧跟蹤:

                  An here is the full stacktrace:

                  java.lang.ExceptionInInitializerError
                  at com.jbo.testapp.AppServletTest.setUp(AppServletTest.java:36)
                  at junit.framework.TestCase.runBare(TestCase.java:128)
                  at junit.framework.TestResult$1.protect(TestResult.java:106)
                  at junit.framework.TestResult.runProtected(TestResult.java:124)
                  at junit.framework.TestResult.run(TestResult.java:109)
                  at junit.framework.TestCase.run(TestCase.java:120)
                  at junit.framework.TestSuite.runTest(TestSuite.java:230)
                  at junit.framework.TestSuite.run(TestSuite.java:225)
                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                  at java.lang.reflect.Method.invoke(Method.java:497)
                  at org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:96)
                  at org.apache.maven.surefire.junit.JUnit3Provider.executeTestSet(JUnit3Provider.java:117)
                  at org.apache.maven.surefire.junit.JUnit3Provider.invoke(JUnit3Provider.java:94)
                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                  at java.lang.reflect.Method.invoke(Method.java:497)
                  at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164)
                  at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110)
                  at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:175)
                  at 
                  
                  org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:107)
                      at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:68)
                  Caused by: java.util.MissingResourceException: Can't find bundle for base name javax.servlet.LocalStrings, locale es_ES
                      at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1564)
                      at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1387)
                      at java.util.ResourceBundle.getBundle(ResourceBundle.java:773)
                      at javax.servlet.GenericServlet.<clinit>(GenericServlet.java:95)
                      ... 24 more
                  Caused by: java.util.MissingResourceException: Can't find bundle for base name javax.servlet.LocalStrings, locale es_ES
                      at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1564)
                      at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1387)
                      at java.util.ResourceBundle.getBundle(ResourceBundle.java:773)
                      at javax.servlet.GenericServlet.<clinit>(GenericServlet.java:95)
                      ... 24 more
                  

                  希望你們能幫助我!提前謝謝你

                  Hope you guys can help me! Thank you in advance

                  推薦答案

                  原因:java.util.MissingResourceException:找不到基本名稱 javax.servlet.LocalStrings 的包,語言環(huán)境 es_ES

                  Caused by: java.util.MissingResourceException: Can't find bundle for base name javax.servlet.LocalStrings, locale es_ES

                  這才是真正的錯(cuò)誤.

                  您正在運(yùn)行的測試缺少 servlet-api 依賴項(xiàng).

                  Your running tests are missing the servlet-api dependency.

                  如果您使用的是 maven,請確保此依賴項(xiàng)存在于您的項(xiàng)目中:

                  If you're using maven make sure this dependency is in your project:

                  <dependency>
                    <groupId>javax.servlet</groupId>
                    <artifactId>javax.servlet-api</artifactId>
                    <version>3.1.0</version>
                  </dependency>
                  

                  這篇關(guān)于java.util.MissingResourceException:找不到基本名稱 javax.servlet.LocalStrings 的包,區(qū)域設(shè)置 es_ES的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  How can I detect integer overflow on 32 bits int?(如何檢測 32 位 int 上的整數(shù)溢出?)
                  Local variables before return statements, does it matter?(return 語句之前的局部變量,這有關(guān)系嗎?)
                  How to convert Integer to int?(如何將整數(shù)轉(zhuǎn)換為整數(shù)?)
                  How do I create an int array with randomly shuffled numbers in a given range(如何在給定范圍內(nèi)創(chuàng)建一個(gè)隨機(jī)打亂數(shù)字的 int 數(shù)組)
                  Inconsistent behavior on java#39;s ==(java的行為不一致==)
                  Why is Java able to store 0xff000000 as an int?(為什么 Java 能夠?qū)?0xff000000 存儲(chǔ)為 int?)

                  <small id='3OzJG'></small><noframes id='3OzJG'>

                  <tfoot id='3OzJG'></tfoot>
                  • <legend id='3OzJG'><style id='3OzJG'><dir id='3OzJG'><q id='3OzJG'></q></dir></style></legend>
                      <tbody id='3OzJG'></tbody>
                      • <bdo id='3OzJG'></bdo><ul id='3OzJG'></ul>
                          <i id='3OzJG'><tr id='3OzJG'><dt id='3OzJG'><q id='3OzJG'><span id='3OzJG'><b id='3OzJG'><form id='3OzJG'><ins id='3OzJG'></ins><ul id='3OzJG'></ul><sub id='3OzJG'></sub></form><legend id='3OzJG'></legend><bdo id='3OzJG'><pre id='3OzJG'><center id='3OzJG'></center></pre></bdo></b><th id='3OzJG'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='3OzJG'><tfoot id='3OzJG'></tfoot><dl id='3OzJG'><fieldset id='3OzJG'></fieldset></dl></div>

                            主站蜘蛛池模板: 欧美精品91| a级大毛片 | 成人h免费观看视频 | 久久综合伊人一区二区三 | 国产精品a久久久久 | 成人免费网站 | 久久综合激情 | 日韩免费视频 | 精品国产乱码久久久久久牛牛 | 日韩看片| 精品一二区 | 一区二区三区欧美在线观看 | 色本道| 成人永久免费视频 | 欧美一区二区三区 | 国产成人福利在线观看 | xx性欧美肥妇精品久久久久久 | 国产高清精品在线 | 精品国产黄a∨片高清在线 www.一级片 国产欧美日韩综合精品一区二区 | 亚洲一区二区三区在线视频 | 久久久久亚洲精品国产 | 国产美女久久 | 欧美性网站 | 日韩在线播放中文字幕 | 国产欧美精品区一区二区三区 | 免费看的黄网站 | 久久国产精品一区二区三区 | 中文一区二区 | 天堂av资源| av二区三区| 精品国产乱码久久久久久闺蜜 | 成人av一区| 国产成人一区在线 | 高清视频一区二区三区 | 日韩在线免费视频 | 色婷婷av777 av免费网站在线 | 伊人电影院av | 网黄在线| 国产精品高潮呻吟 | 国产精品小视频在线观看 | 久久99精品久久久久久 |