我正在尝试使用angularjs和spring MVC上传文件
我在application-context.xml中有一个multipartResolver bean.
<mvc:annotation-driven />
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize" value="2097152" />
</bean>
Run Code Online (Sandbox Code Playgroud)
我的表格看起来像这样:
<form method="post" id="fromFileUpload" enctype="multipart/form-data"
ng-submit="continueFileUpload()">
<div class="form-group">
<label class="control-label col-sm-4 col-xs-12" for="quoteIdentifier">Quote Identifier : </label>
<div class="col-xs-4 input-max">
<select type="text" class="form-control " name="quoteIdentifier" id="quoteIdentifier" ng-model="quoteIdentifier" ng-options="">
<option style="display: none" value="">Choose</option>
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-4 col-xs-12" for="file">Please upload the file : <span class="required">*</span> </label>
<div class="col-xs-4 input-max controls ">
<input class="inline-block" type="file" name="file" ng-model="file" data-rule-required="true" id="file" accept=".csv,.xsl,.xml,.mpp,application/vnd.ms-excel">
</div>
<span id="vaildFile" class="text-success icon-ok …Run Code Online (Sandbox Code Playgroud) 我有一个应用程序在嵌入式jetty服务器上运行.现在我想启动/停止服务器作为服务.我使用脚本启动服务器.
java $JAVA_OPTS -DREQ_JAVA_VERSION=$JAVA_VERSION -jar myjetty.jar
Run Code Online (Sandbox Code Playgroud)
主类
Server server = new Server();
SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(PORT);
server.addConnector(connector);
HandlerCollection handlers = new HandlerCollection();
NCSARequestLog requestLog = new NCSARequestLog();
requestLog.setFilename(home + "/logs/access_" + logFileDateFormat
+ ".log");
requestLog.setFilenameDateFormat(logFileDateFormat);
requestLog.setRetainDays(10);
requestLog.setAppend(true);
requestLog.setExtended(false);
requestLog.setLogCookies(false);
requestLog.setLogTimeZone(TimeZone.getDefault().getID());
RequestLogHandler requestLogHandler = new RequestLogHandler();
requestLogHandler.setRequestLog(requestLog);
handlers.addHandler(requestLogHandler);
server.setHandler(handlers);
server.start();
server.join();
Run Code Online (Sandbox Code Playgroud)
这启动了服务器.通过Web调用停止和/或重新启动嵌入式Jetty实例可用于停止服务器但是,如何从脚本中停止服务器?我应该做些什么来改变主类中的服务器.
我想使用jetty启动我的应用程序,所以我添加了下面提到的依赖项.当我运行主方法Jetty成功启动.(我正在开发一个struts2 + spring3 + hibernate maven项目,我也可以在tomcat中部署它)
现在我想从战争包装pom创建一个可执行jar.所以我在我的pom中添加了maven-assembly-plugin.(我尝试使用maven jar插件,但它没有添加依赖项)
插件
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<archive>
<manifest>
<mainClass>com.dca.engine.StartDCA</mainClass>
</manifest>
</archive>
<packagingExcludes>WEB-INF/lib/jetty*.jar,WEB-INF/lib/org.apache.taglibs.standard.glassfish*.jar,WEB-INF/lib/org.apache.jasper.glassfish*.jar,WEB-INF/lib/org.eclipse.jdt.core*.jar,WEB-INF/lib/javax.servlet.jsp*.jar,WEB-INF/lib/javax.el*.jar</packagingExcludes>
<escapeString>\</escapeString>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.dca.engine.StartDCA</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.java</include>
<include>**/*.xml</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
Run Code Online (Sandbox Code Playgroud)
嵌入式Jetty
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>8.1.10.v20130312</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>8.1.10.v20130312</version>
<!-- <scope>provided</scope> -->
</dependency> …Run Code Online (Sandbox Code Playgroud) 我正在研究球衣服务,我在这里提到它在我返回一个java对象时工作正常.后来我试图让java对象通用它给出异常 javax.ws.rs.WebApplicationException:javax.xml.bind.MarshalException
@XmlRootElement
public class AppObject<T> implements Serializable {
private List<T> list;
private String license;
public AppObject() {
list = new ArrayList<T>();
}
public AppObject(List<T> list) {
this.list = list;
}
@XmlAnyElement(lax = true)
public List<T> getList() {
return list;
}
public void setList(List<T> list) {
this.list = list;
}
public String getLicense() {
return license;
}
public void setLicense(String license) {
this.license = license;
}
}
Run Code Online (Sandbox Code Playgroud)
我的服务
@GET
@Produces({MediaType.APPLICATION_XML ,MediaType.APPLICATION_JSON})
@Path("/getreq")
public AppObject<DimRequirement> savePayment() {
AppObject<DimRequirement> appObject …Run Code Online (Sandbox Code Playgroud) java ×4
spring ×2
angularjs ×1
jaxb ×1
jersey ×1
jetty ×1
maven ×1
spring-mvc ×1
web-services ×1