- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
-6ren">
我的项目文件夹中有这些文件
build.xml
version="1.0"?>
<property name="src.dir" value="src"/>
<property name="web.dir" value="war"/>
<property name="build.dir" value="${web.dir}/WEB-INF/classes"/>
<property name="test.dir" value="test"/>
<property name="name" value="HelloWorld"/>
<path id="master-classpath">
<fileset dir="${web.dir}/WEB-INF/lib">
<include name="*.jar"/>
</fileset>
<!-- We need the servlet API classes: -->
<!-- * for Tomcat 5/6 use servlet-api.jar -->
<!-- * for other app servers - check the docs -->
<fileset dir="${appserver.lib}">
<include name="servlet*.jar"/>
</fileset>
<pathelement path="${build.dir}"/>
</path>
<target name="usage">
<echo message=""/>
<echo message="${name} build file"/>
<echo message="-----------------------------------"/>
<echo message=""/>
<echo message="Available targets are:"/>
<echo message=""/>
<echo message="build --> Build the application"/>
<echo message="deploy --> Deploy application as directory"/>
<echo message="deploywar --> Deploy application as a WAR file"/>
<echo message="start-webapp --> Start application in Tomcat"/>
<echo message="stop-webapp --> Stop application in Tomcat"/>
<echo message="deploy-webapp --> Deploy application in Tomcat"/>
<echo message="undeploy-webapp --> Undeploy application in Tomcat"/>
<echo message="list --> List Tomcat applications"/>
<echo message=""/>
</target>
<target name="build" description="Compile main source tree java files">
<mkdir dir="${build.dir}"/>
<javac destdir="${build.dir}" debug="true"
deprecation="false" optimize="false" failonerror="true">
<src path="${src.dir}"/>
<classpath refid="master-classpath"/>
</javac>
</target>
<target name="buildtests" description="Building All TestCases">
<mkdir dir="${build.dir}"/>
<javac destdir="${build.dir}" source="1.5" target="1.5" debug="true"
deprecation="false" optimize="false" failonerror="true">
<src path="${test.dir}"/>
<classpath refid="master-classpath"/>
</javac>
</target>
<target name="clean" description="Cleaning All build files">
<delete>
<fileset dir="${build.dir}">
<include name="**/*.class"/>
</fileset>
</delete>
</target>
<target name="tests" depends="build,buildtests" description="Running All TestCases">
<junit printsummary="on" fork="false" haltonfailure="false" failureproperty="tests.failed"
showoutput="true">
<classpath refid="master-classpath"/>
<formatter type="brief" usefile="false"/>
<batchtest>
<fileset dir="${build.dir}">
<include name="**/*Tests.*"/>
</fileset>
</batchtest>
</junit>
<fail if="tests.failed">
tests.failed=${tests.failed}
***********************************************************
***********************************************************
**** One or more tests failed! Check the output ... ****
***********************************************************
***********************************************************
</fail>
</target>
<target name="deploy" depends="build" description="Deploy application">
<copy todir="${deploy.path}/${name}" preservelastmodified="true">
<fileset dir="${web.dir}">
<include name="**/*.*"/>
</fileset>
</copy>
</target>
<target name="deploywar" depends="build" description="Deploy application as a WAR file">
<war destfile="${name}.war"
needxmlfile="false">
<fileset dir="${web.dir}">
<include name="**/*.*"/>
</fileset>
</war>
<copy todir="${deploy.path}" preservelastmodified="true">
<fileset dir=".">
<include name="*.war"/>
</fileset>
</copy>
</target>
<!-- ============================================================== -->
<!-- Tomcat tasks - remove these if you don't have Tomcat installed -->
<!-- ============================================================== -->
<path id="catalina-ant-classpath">
<!-- We need the Catalina jars for Tomcat -->
<!-- * for other app servers - check the docs -->
<fileset dir="${appserver.lib}">
<include name="catalina-ant.jar"/>
<include name="tomcat-coyote.jar"/>
<include name="tomcat-util.jar"/>
</fileset>
<fileset dir="${appserver.home}/bin">
<include name="tomcat-juli.jar"/>
</fileset>
</path>
<taskdef name="catalina-deploy" classname="org.apache.catalina.ant.DeployTask" classpathref="catalina-ant-classpath"/>
<taskdef name="catalina-list" classname="org.apache.catalina.ant.ListTask" classpathref="catalina-ant-classpath"/>
<taskdef name="catalina-reload" classname="org.apache.catalina.ant.ReloadTask" classpathref="catalina-ant-classpath"/>
<taskdef name="catalina-findleaks" classname="org.apache.catalina.ant.FindLeaksTask" classpathref="catalina-ant-classpath"/>
<taskdef name="catalina-resources" classname="org.apache.catalina.ant.ResourcesTask" classpathref="catalina-ant-classpath"/>
<taskdef name="catalina-start" classname="org.apache.catalina.ant.StartTask" classpathref="catalina-ant-classpath"/>
<taskdef name="catalina-stop" classname="org.apache.catalina.ant.StopTask" classpathref="catalina-ant-classpath"/>
<taskdef name="catalina-undeploy" classname="org.apache.catalina.ant.UndeployTask" classpathref="catalina-ant-classpath"/>
<target name="start-webapp" description="Start application in Tomcat">
<catalina-start url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"
path="/${name}" />
</target>
<target name="stop-webapp" description="Stop application in Tomcat">
<catalina-stop url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"
path="/${name}" />
</target>
<target name="deploy-webapp" description="Deploy application in Tomcat">
<catalina-deploy url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"
path="/${name}"
war="file:${deploy.path}/${name}.war"/>
</target>
<target name="undeploy-webapp" description="Undeploy Tomcat application">
<catalina-undeploy url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"
path="/${name}"/>
</target>
<target name="list" description="List Tomcat applications">
<catalina-list url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"/>
</target>
<target name="reload" description="Reload Application in Tomcat">
<catalina-reload url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"
path="/${name}"/>
</target>
<!-- End Tomcat tasks -->
AppIntializer.java
package HelloWorld.web.config;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration.Dynamic;
import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;
public class AppInitializer implements WebApplicationInitializer {
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
ctx.register(AppConfig.class);
ctx.setServletContext(servletContext);
Dynamic dynamic = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx));
dynamic.addMapping("/");
dynamic.setLoadOnStartup(1);
}
}
AppConfig.java
package HelloWorld.web.config;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
@Configuration
@EnableWebMvc
@ComponentScan(basePackages = "HelloWorld.web")
public class AppConfig {
}
Person.java
package HelloWorld.web.POJO;
public class Person {
private String id;
private String name;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
HelloController.java
package HelloWorld.web.controller;
import HelloWorld.web.POJO.Person;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/data")
public class HelloController {
protected final Log logger = LogFactory.getLog(getClass());
@RequestMapping(value = "/persons", method = RequestMethod.GET, headers="Accept=application/json")
public Person handleRequest() {
Person person = new Person();
person.setId("1");
person.setName("Kuch");
return person;
}
}
lib 文件夹包含 spring、jackson、servlet-api、common-logging jar
commons-logging-1.2-javadoc.jar
commons-logging-1.2.jar
hamcrest-core-1.3.jar
jackson-core-2.9.3.jar
junit-4.12.jar
servlet-api.jar
spring-aop-5.0.2.RELEASE-javadoc.jar
spring-aop-5.0.2.RELEASE-sources.jar
spring-aop-5.0.2.RELEASE.jar
spring-aspects-5.0.2.RELEASE-javadoc.jar
spring-aspects-5.0.2.RELEASE-sources.jar
spring-aspects-5.0.2.RELEASE.jar
spring-beans-5.0.2.RELEASE-javadoc.jar
spring-beans-5.0.2.RELEASE-sources.jar
spring-beans-5.0.2.RELEASE.jar
spring-context-5.0.2.RELEASE-javadoc.jar
spring-context-5.0.2.RELEASE-sources.jar
spring-context-5.0.2.RELEASE.jar
spring-context-indexer-5.0.2.RELEASE-javadoc.jar
spring-context-indexer-5.0.2.RELEASE-sources.jar
spring-context-indexer-5.0.2.RELEASE.jar
spring-context-support-5.0.2.RELEASE-javadoc.jar
spring-context-support-5.0.2.RELEASE-sources.jar
spring-context-support-5.0.2.RELEASE.jar
spring-core-5.0.2.RELEASE-javadoc.jar
spring-core-5.0.2.RELEASE-sources.jar
spring-core-5.0.2.RELEASE.jar
spring-expression-5.0.2.RELEASE-javadoc.jar
spring-expression-5.0.2.RELEASE-sources.jar
spring-expression-5.0.2.RELEASE.jar
spring-instrument-5.0.2.RELEASE-javadoc.jar
spring-instrument-5.0.2.RELEASE-sources.jar
spring-instrument-5.0.2.RELEASE.jar
spring-jcl-5.0.2.RELEASE-javadoc.jar
spring-jcl-5.0.2.RELEASE-sources.jar
spring-jcl-5.0.2.RELEASE.jar
spring-jdbc-5.0.2.RELEASE-javadoc.jar
spring-jdbc-5.0.2.RELEASE-sources.jar
spring-jdbc-5.0.2.RELEASE.jar
spring-jms-5.0.2.RELEASE-javadoc.jar
spring-jms-5.0.2.RELEASE-sources.jar
spring-jms-5.0.2.RELEASE.jar
spring-messaging-5.0.2.RELEASE-javadoc.jar
spring-messaging-5.0.2.RELEASE-sources.jar
spring-messaging-5.0.2.RELEASE.jar
spring-orm-5.0.2.RELEASE-javadoc.jar
spring-orm-5.0.2.RELEASE-sources.jar
spring-orm-5.0.2.RELEASE.jar
spring-oxm-5.0.2.RELEASE-javadoc.jar
spring-oxm-5.0.2.RELEASE-sources.jar
spring-oxm-5.0.2.RELEASE.jar
spring-test-5.0.2.RELEASE-javadoc.jar
spring-test-5.0.2.RELEASE-sources.jar
spring-test-5.0.2.RELEASE.jar
spring-tx-5.0.2.RELEASE-javadoc.jar
spring-tx-5.0.2.RELEASE-sources.jar
spring-tx-5.0.2.RELEASE.jar
spring-web-5.0.2.RELEASE-javadoc.jar
spring-web-5.0.2.RELEASE-sources.jar
spring-web-5.0.2.RELEASE.jar
spring-webflux-5.0.2.RELEASE-javadoc.jar
spring-webflux-5.0.2.RELEASE-sources.jar
spring-webflux-5.0.2.RELEASE.jar
spring-webmvc-5.0.2.RELEASE-javadoc.jar
spring-webmvc-5.0.2.RELEASE-sources.jar
spring-webmvc-5.0.2.RELEASE.jar
spring-websocket-5.0.2.RELEASE-javadoc.jar
spring-websocket-5.0.2.RELEASE-sources.jar
spring-websocket-5.0.2.RELEASE.jar
当我尝试点击 http://localhost:8080/HelloWorld/data/persons 时它给出了这个错误HTTP 状态 406 – Not Acceptable
类型状态报告
描述 根据请求中收到的主动协商 header 字段,目标资源没有用户代理可以接受的当前表示,并且服务器不愿意提供默认表示。Apache Tomcat/8.5.24
请尝试解决。
最佳答案
感谢您在我添加 jackson-all-1.0.9 并将对象转换为字符串时解决了这个问题。
关于java - 运行 Spring WebApp 时代码状态 406,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48252313/
SQLite、Content provider 和 Shared Preference 之间的所有已知区别。 但我想知道什么时候需要根据情况使用 SQLite 或 Content Provider 或
警告:我正在使用一个我无法完全控制的后端,所以我正在努力解决 Backbone 中的一些注意事项,这些注意事项可能在其他地方更好地解决......不幸的是,我别无选择,只能在这里处理它们! 所以,我的
我一整天都在挣扎。我的预输入搜索表达式与远程 json 数据完美配合。但是当我尝试使用相同的 json 数据作为预取数据时,建议为空。点击第一个标志后,我收到预定义消息“无法找到任何内容...”,结果
我正在制作一个模拟 NHL 选秀彩票的程序,其中屏幕右侧应该有一个 JTextField,并且在左侧绘制弹跳的选秀球。我创建了一个名为 Ball 的类,它实现了 Runnable,并在我的主 Draf
这个问题已经有答案了: How can I calculate a time span in Java and format the output? (18 个回答) 已关闭 9 年前。 这是我的代码
我有一个 ASP.NET Web API 应用程序在我的本地 IIS 实例上运行。 Web 应用程序配置有 CORS。我调用的 Web API 方法类似于: [POST("/API/{foo}/{ba
我将用户输入的时间和日期作为: DatePicker dp = (DatePicker) findViewById(R.id.datePicker); TimePicker tp = (TimePic
放宽“邻居”的标准是否足够,或者是否有其他标准行动可以采取? 最佳答案 如果所有相邻解决方案都是 Tabu,则听起来您的 Tabu 列表的大小太长或您的释放策略太严格。一个好的 Tabu 列表长度是
我正在阅读来自 cppreference 的代码示例: #include #include #include #include template void print_queue(T& q)
我快疯了,我试图理解工具提示的行为,但没有成功。 1. 第一个问题是当我尝试通过插件(按钮 1)在点击事件中使用它时 -> 如果您转到 Fiddle,您会在“内容”内看到该函数' 每次点击都会调用该属
我在功能组件中有以下代码: const [ folder, setFolder ] = useState([]); const folderData = useContext(FolderContex
我在使用预签名网址和 AFNetworking 3.0 从 S3 获取图像时遇到问题。我可以使用 NSMutableURLRequest 和 NSURLSession 获取图像,但是当我使用 AFHT
我正在使用 Oracle ojdbc 12 和 Java 8 处理 Oracle UCP 管理器的问题。当 UCP 池启动失败时,我希望关闭它创建的连接。 当池初始化期间遇到 ORA-02391:超过
关闭。此题需要details or clarity 。目前不接受答案。 想要改进这个问题吗?通过 editing this post 添加详细信息并澄清问题. 已关闭 9 年前。 Improve
引用这个plunker: https://plnkr.co/edit/GWsbdDWVvBYNMqyxzlLY?p=preview 我在 styles.css 文件和 src/app.ts 文件中指定
为什么我的条形这么细?我尝试将宽度设置为 1,它们变得非常厚。我不知道还能尝试什么。默认厚度为 0.8,这是应该的样子吗? import matplotlib.pyplot as plt import
当我编写时,查询按预期执行: SELECT id, day2.count - day1.count AS diff FROM day1 NATURAL JOIN day2; 但我真正想要的是右连接。当
我有以下时间数据: 0 08/01/16 13:07:46,335437 1 18/02/16 08:40:40,565575 2 14/01/16 22:2
一些背景知识 -我的 NodeJS 服务器在端口 3001 上运行,我的 React 应用程序在端口 3000 上运行。我在 React 应用程序 package.json 中设置了一个代理来代理对端
我面临着一个愚蠢的问题。我试图在我的 Angular 应用程序中延迟加载我的图像,我已经尝试过这个2: 但是他们都设置了 src attr 而不是 data-src,我在这里遗漏了什么吗?保留 d
我是一名优秀的程序员,十分优秀!