Java Build Path Error
이클립스 에러 Multiple annotations found at this line: – The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path 진행중인 프로젝트 에서 속성-> Project Facts 에서 자바 runtime 을 톰켓버전에 맞추어 체크 한다.
이클립스 에러 Multiple annotations found at this line: – The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path 진행중인 프로젝트 에서 속성-> Project Facts 에서 자바 runtime 을 톰켓버전에 맞추어 체크 한다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
<!DOCTYPE html> <html> <body> <p>XMLHttpRequest sample </p> <p id="demo">dd</p> <script> function airline(code) { //var decode = code; var xmlHttp = new XMLHttpRequest(); xmlHttp.open( "GET", "https://code.auctpro.co.kr/airline.php?code=" + code, false ); xmlHttp.send( null ); document.getElementById("demo").innerHTML = xmlHttp.responseText; //decode = xmlHttp.responseText; //return decode; } airline('KE'); </script> </body> </html> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
DateTime dt = new DateTime(2008, 3, 9, 16, 5, 7, 123); String.Format("{0:y yy yyy yyyy}", dt); // "8 08 008 2008" year String.Format("{0:M MM MMM MMMM}", dt); // "3 03 Mar March" month String.Format("{0:d dd ddd dddd}", dt); // "9 09 Sun Sunday" day String.Format("{0:h hh H HH}", dt); // "4 04 16 16" hour 12/24 String.Format("{0:m mm}", dt); // "5 05" minute String.Format("{0:s ss}", dt); // "7 07" second String.Format("{0:f ff fff ffff}", dt); // "1 12 123 1230" sec.fraction String.Format("{0:F FF FFF FFFF}", dt); // "1 12 123 123" without zeroes String.Format("{0:t tt}", dt); // "P PM" A.M. or P.M. String.Format("{0:z zz zzz}", dt); // "-6 -06 -06:00" time zone |
1 2 3 4 |
String.Format("{0:d/M/yyyy HH:mm:ss}", dt); // "9/3/2008 16:05:07" - english (en-US) String.Format("{0:d/M/yyyy HH:mm:ss}", dt); // "9.3.2008 16:05:07" - german (de-DE) |
1 2 3 4 5 6 7 8 9 10 11 12 |
tring.Format("{0:M/d/yyyy}", dt); // "3/9/2008" String.Format("{0:MM/dd/yyyy}", dt); // "03/09/2008" // day/month names String.Format("{0:ddd, MMM d, yyyy}", dt); // "Sun, Mar 9, 2008" String.Format("{0:dddd, MMMM d, yyyy}", dt); // "Sunday, March 9, 2008" // two/four digit year String.Format("{0:MM/dd/yy}", dt); // "03/09/08" String.Format("{0:MM/dd/yyyy}", dt); // "03/09/2008" |
Standard DateTime Formatting In DateTimeFormatInfo there are defined standard patterns for the current culture. For example property ShortTimePattern is string that contains value h:mm tt for en-US culture and value HH:mm for de-DE culture. Following table shows patterns defined in DateTimeFormatInfo and their values for en-US culture. First column contains format specifiers… Read More »
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using Microsoft.Extensions.DependencyInjection; using Microsoft.AspNetCore; using Microsoft.Extensions.Configuration; using Microsoft.AspNetCore.Mvc; using System.Net.Http.Headers; namespace StartupBasic { public class Startup { public Startup(IHostingEnvironment env, ILoggerFactory logger, IConfiguration configuration) { //These are three services available at constructor } public void ConfigureServices(IServiceCollection services) { services.AddMvcCore(). SetCompatibilityVersion(CompatibilityVersion.Version_2_1); } public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory logger, IConfiguration configuration) { app.UseMvc(routes => routes.MapRoute( name: "default_route", template: "{controller}/{action}/{id?}", defaults: new { controller = "Home", action = "Index" }) ); } } public class HomeController : Controller { IHostingEnvironment _env; public HomeController(IHostingEnvironment env) { _env = env; } public ActionResult Index() { return new ContentResult { Content = "<html><body><h1>Download File</h1>Download a copy of <a href=\"/home/hegel\">Hegel (pdf)</a></body></html>", ContentType = "text/html" }; } //public FileStreamResult Hegel() //{ // var pathToIdeas = System.IO.Path.Combine(_env.WebRootPath, "hegel.pdf"); // //This is a contrite example to demonstrate returning a stream. If you have a physical file on disk, just use PhySicalFileResult that takes a path. // return new FileStreamResult(System.IO.File.OpenRead(pathToIdeas), "application/pdf") // { // FileDownloadName = "hegel.pdf" // }; //} public PhysicalFileResult Hegel() { var pathToIdeas = System.IO.Path.Combine(_env.WebRootPath, "hegel.pdf"); return new PhysicalFileResult(pathToIdeas, "application/pdf"); } } public class Program { public static void Main(string[] args) { CreateWebHostBuilder(args).Build().Run(); } public static IWebHostBuilder CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args) .UseStartup<Startup>() .UseEnvironment("Development"); } } |
결과 : Download File Download a copy of Hegel (pdf)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using Microsoft.Extensions.DependencyInjection; using Microsoft.AspNetCore; using Microsoft.Extensions.Configuration; using Microsoft.AspNetCore.Mvc; namespace MvcRouting { public class Startup { public Startup(IHostingEnvironment env, ILoggerFactory logger, IConfiguration configuration) { //These are three services available at constructor } public void ConfigureServices(IServiceCollection services) { services.AddMvcCore(). SetCompatibilityVersion(CompatibilityVersion.Version_2_1); } public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory logger, IConfiguration configuration) { app.UseMvc(); } } [Route("[controller]/[action]")] public class HomeController : Controller { [HttpGet("/")] [HttpGet("")] public ActionResult Index() { return new ContentResult { Content = @" <html><body> <h1>[controller] and [action] replacement tokens examples</h1> <ul> <li><a href=""/"">/</a></li> <li><a href=""/home/index"">/home/index</a></li> <li><a href=""/home/about"">/home/about</a></li> <li><a href=""/about"">/about</a></li> </ul> </body></html>", ContentType = "text/html" }; } public ActionResult About() { return new ContentResult { Content = @" <html><body> <b>About Page</b </body></html>", ContentType = "text/html" }; } [HttpGet("/about")] public ActionResult About2() { return new ContentResult { Content = @" <html><body> <b>About Page 2</b </body></html>", ContentType = "text/html" }; } } public class Program { public static void Main(string[] args) { CreateWebHostBuilder(args).Build().Run(); } public static IWebHostBuilder CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args) .UseStartup<Startup>() .UseEnvironment("Development"); } } |
결과 : [controller] replacement token examples •/ •/home/ •/home/about •/about
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using Microsoft.Extensions.DependencyInjection; using Microsoft.AspNetCore; using Microsoft.Extensions.Configuration; using Microsoft.AspNetCore.Mvc; namespace MvcRouting { public class Startup { public Startup(IHostingEnvironment env, ILoggerFactory logger, IConfiguration configuration) { //These are three services available at constructor } public void ConfigureServices(IServiceCollection services) { services.AddMvcCore(). SetCompatibilityVersion(CompatibilityVersion.Version_2_1); } public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory logger, IConfiguration configuration) { app.UseMvc(); } } [Route("[controller]")] public class HomeController : Controller { [HttpGet("/")] [HttpGet("")] //You have to do this otherwise /Home/Index won't work public ActionResult Index() { return new ContentResult { Content = @" <html><body> <h1>[controller] replacement token examples</h1> <ul> <li><a href=""/"">/</a></li> <li><a href=""/home/"">/home/</a></li> <li><a href=""/home/about"">/home/about</a></li> <li><a href=""/about"">/about</a></li> </ul> </body></html>", ContentType = "text/html" }; } [HttpGet("about")] public ActionResult About() { return new ContentResult { Content = @" <html><body> <b>About Page</b </body></html>", ContentType = "text/html" }; } [HttpGet("/about")] public ActionResult About2() { return new ContentResult { Content = @" <html><body> <b>About Page 2</b </body></html>", ContentType = "text/html" }; } } public class Program { public static void Main(string[] args) { CreateWebHostBuilder(args).Build().Run(); } public static IWebHostBuilder CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args) .UseStartup<Startup>() .UseEnvironment("Development"); } } |
결과 : [controller] replacement token examples •/ •/home/ •/home/about •/about
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using Microsoft.Extensions.DependencyInjection; using Microsoft.AspNetCore; using Microsoft.Extensions.Configuration; using Microsoft.AspNetCore.Mvc; namespace MvcRouting { public class Startup { public Startup(IHostingEnvironment env, ILoggerFactory logger, IConfiguration configuration) { //These are three services available at constructor } public void ConfigureServices(IServiceCollection services) { services.AddMvcCore(). SetCompatibilityVersion(CompatibilityVersion.Version_2_1); } public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory logger, IConfiguration configuration) { app.UseMvc(routes => { routes.MapRoute( name: "home", template: "/", defaults: new { controller = "Home", action = "Index" }); routes.MapRoute( name: "default", template: "{controller}/{action}", defaults: new { controller = "Home", action = "Index" }); }); } } public class HomeController : Controller { public ActionResult Index() { return new ContentResult { Content = @" <html><body> <b>Hello World</b> <br/><br/> The following links call the same controller and action. <ul> <li><a href=""/"">/</a></li> <li><a href=""/Home"">/Home</a></li> <li><a href=""/Home/index"">/Home/index</a></li> </ul> </body></html>", ContentType = "text/html" }; } } public class Program { public static void Main(string[] args) { CreateWebHostBuilder(args).Build().Run(); } public static IWebHostBuilder CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args) .UseStartup<Startup>() .UseEnvironment("Development"); } } |
결과 : Hello World The following links call the same controller and action. •/ •/home •/home/index 동일 :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
namespace MvcRouting { public class Startup { public Startup(IHostingEnvironment env, ILoggerFactory logger, IConfiguration configuration) { //These are three services available at constructor } public void ConfigureServices(IServiceCollection services) { services.AddMvcCore(). SetCompatibilityVersion(CompatibilityVersion.Version_2_1); } public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory logger, IConfiguration configuration) { app.UseMvc(); } } [Route("")] [Route("Home")] [Route("Home/Index")] public class HomeController : Controller { public ActionResult Index() { return new ContentResult { Content = @" <html><body> <b>Hello World</b> <br/><br/> The following links call the same controller and action. <ul> <li><a href=""/"">/</a></li> <li><a href=""/home"">/home</a></li> <li><a href=""/home/index"">/home/index</a></li> </ul> </body></html>", ContentType = "text/html" }; } } public class Program { public static void Main(string[] args) { CreateWebHostBuilder(args).Build().Run(); } public static IWebHostBuilder CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args) .UseStartup<Startup>() .UseEnvironment("Development"); } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using Microsoft.Extensions.DependencyInjection; using Microsoft.AspNetCore; using Microsoft.Extensions.Configuration; using Microsoft.AspNetCore.Mvc; namespace StartupBasic { public class Startup { public Startup(IHostingEnvironment env, ILoggerFactory logger, IConfiguration configuration) { //These are three services available at constructor } public void ConfigureServices(IServiceCollection services) { services.AddMvcCore(). SetCompatibilityVersion(CompatibilityVersion.Version_2_1); } public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory logger, IConfiguration configuration) { app.UseMvc(routes => routes.MapRoute( name: "default_route", template: "{controller}/{action}/{id?}", defaults: new { controller = "Home", action = "Index" }) ); } } public class HomeController : Controller { public ActionResult Index() { return new ContentResult { Content = "<html><body><b>Hello World</b></body></html>", ContentType = "text/html" }; } } public class Program { public static void Main(string[] args) { CreateWebHostBuilder(args).Build().Run(); } public static IWebHostBuilder CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args) .UseStartup<Startup>() .UseEnvironment("Development"); } } |
결과 : Hello World
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; using Microsoft.AspNetCore.Routing; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Mvc.Formatters; namespace MvcOutputXml { public class Startup { public void ConfigureServices(IServiceCollection services) { services.AddMvc(config => { config.OutputFormatters.Add(new XmlSerializerOutputFormatter()); }); } public void Configure(IApplicationBuilder app) { app.UseMvc(); } } public class Greeting { public bool Hello { get; set; } public bool World { get; set; } } public class HomeController : Controller { [HttpGet("")] public IActionResult Index() { var h = new Greeting { Hello = true, World = true }; Response.ContentType = "text/xml"; return Ok(h); } } public class Program { public static void Main(string[] args) { CreateWebHostBuilder(args).Build().Run(); } public static IWebHostBuilder CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args) .UseStartup<Startup>() .UseEnvironment("Development"); } } |
결과
1 2 3 4 5 6 7 |
<?xml version="1.0"?> <Greeting xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Hello>true</Hello> <World>true</World> </Greeting> |