我提到了很多帖子,但我仍然无法找到正确的工作答案.
我希望从我的Java类本身获取它,而不是在jsp中使用EL.
如何在Spring中获取servlet上下文路径?
我有2个属性文件.我已经提到了这两个文件context:property-placeholder......
<context:property-placeholder location="conf/ConfServer.conf,conf/LicenseSettings.properties" />
Run Code Online (Sandbox Code Playgroud)
我也尝试过这个
<context:property-placeholder location="conf/ConfServer.conf,conf/LicenseSettings.properties" />
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>conf/LicenseSettings.properties</value>
</list>
</property>
<property name="ignoreUnresolvablePlaceholders" value="true"/>
</bean>
Run Code Online (Sandbox Code Playgroud)
我尝试的上述两种方法都不起作用.
任何人都可以发现错误并帮助我解决这个问题吗?
我已经提到了这一点,但它对我没有用.
我有一个jsp带有此代码段的代码片段.
<form name="AudioFileConversionForm" enctype="multipart/form-data" method="post" >
Choose File: <input type="file" id="audioFile" name="audioFile"><br>
<input type="submit" value="upload">
</form>
Run Code Online (Sandbox Code Playgroud)
这是我的控制器spring.
public String convertFile(HttpServletRequest request, HttpSession session) {
String audioFile = request.getParameter("audioFile");
System.out.println(request.getParameter("audioFile"));
System.out.println("Audio File Conversion Successful");
}
Run Code Online (Sandbox Code Playgroud)
它显示我无法检索文件的名称null.我知道我可以使用JQuery或javascript检索名称,但我不想同时使用它们.我想用纯java来做.谁能帮帮我吗?
我已设置JAVA_HOME为C:\Program Files\Java\jdk1.5.0_11
已设置Classpath为C:\Program Files\Java\jre1.5.0_11
我已经设定了路径
C:\Ruby193\bin;C:\XEClient\bin;
F:\oracle\product\10.2.0\db_2\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;
C:\Program Files\Java\jdk1.6.0_17\bin;
C:\Program Files\jEdit;C:\Program Files\TortoiseSVN\bin;
C:\Program Files\Microsoft SQL Server\90\Tools\binn\
现在我的问题是,versiontomcat运行的是什么java?
tomcat控制台编写整个"路径",
并cmd说它是当前在系统中运行的java版本7.
有人请帮帮我..我的系统中安装了java 5,6,7版本,还有tomcat 5,6,7.
现在什么是tomcat的java版本和系统的java版本???
为什么在以下基本示例中返回的集合在渲染函数内是空的?
自动发布已启用.页面加载
Coll.find().fetch()javascript控制台内的调用命令后返回正确的条目集
这是代码
t.js
Coll = new Meteor.Collection("coll");
if (Meteor.isClient) {
Template.tpl.rendered = function(){
console.log(Coll.find().fetch()); // <-- This line prints empty array
};
}
if (Meteor.isServer) {
Meteor.startup(function () {
if (Coll.find().count() === 0) {
var f = ["foo","bar"];
for (var i = 0; i < f.length; i++)
Coll.insert({f: f[i]});
}
});
}
Run Code Online (Sandbox Code Playgroud)
并t.html提交
<head>
<title>test</title>
</head>
<body>
{{> tpl}}
</body>
<template name="tpl">
Test tpl
</template>
Run Code Online (Sandbox Code Playgroud) beans.xml在我们EJB和jar文件中开始使用文件后,我有一个非常奇怪的异常.
我们使用JBoss7.1.1发布.
我们的应用程序打包为ear文件.
它之前已部署并正常运行.
有一些Module1 EJB组件.现在我们@Inject annotation在Module1中使用一些bean,因此添加了META-INF/beans.xml.
另一个EJB组件Module2使用Module1中的EJB,如:
@EJB
private IOmistajaFinderLocal omistajaFinder;
但现在应用程序无法部署在JBoss上.有以下例外:
java.lang.UnsupportedOperationException: JBAS011859: Naming context is read-only
at org.jboss.as.naming.WritableServiceBasedNamingStore.requireOwner(WritableServiceBasedNamingStore.java:126)
at org.jboss.as.naming.WritableServiceBasedNamingStore.createSubcontext(WritableServiceBasedNamingStore.java:116)
at org.jboss.as.naming.NamingContext.createSubcontext(NamingContext.java:338)
at org.jboss.as.naming.InitialContext.createSubcontext(InitialContext.java:229)
at org.jboss.as.naming.NamingContext.createSubcontext(NamingContext.java:346)
at javax.naming.InitialContext.createSubcontext(Unknown Source)
at com.sun.jersey.server.impl.cdi.CDIExtension$1.stepInto(CDIExtension.java:280)
at com.sun.jersey.server.impl.cdi.CDIExtension.diveIntoJNDIContext(CDIExtension.java:267)
at com.sun.jersey.server.impl.cdi.CDIExtension.createJerseyConfigJNDIContext(CDIExtension.java:273)
at com.sun.jersey.server.impl.cdi.CDIExtension.initialize(CDIExtension.java:192)
at com.sun.jersey.server.impl.cdi.CDIExtension.beforeBeanDiscovery(CDIExtension.java:297)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:264)
at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52)
at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:137)
at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:260)
at org.jboss.weld.introspector.jlr.WeldMethodImpl.invokeOnInstance(WeldMethodImpl.java:170)
at org.jboss.weld.introspector.ForwardingWeldMethod.invokeOnInstance(ForwardingWeldMethod.java:51)
at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:154)
at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:241)
at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:229)
at …Run Code Online (Sandbox Code Playgroud) 我知道这是重复的,你们会因为它而责备我,但在阅读完所有帖子后我没有得到适当的解决方案.
我试图在Spring Source Tool Suite中构建一个Spring Template应用程序.我收到以下错误.
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:来自ServletContext资源[/WEB-INF/spring/appServlet/servlet-context.xml]的XML文档中的第16行无效; 嵌套异常是org.xml.sax.SAXParseException:cvc-complex-type.2.4.c:匹配的通配符是strict,但是没有为元素'resources'找到声明.
我的root-context.xml是这样的:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:cache="http://www.springframework.org/schema/cache"
xmlns:ehcache="http://www.springmodules.org/schema/ehcache"
xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springmodules.org/schema/ehcache http://www.springmodules.org/schema/cache/springmodules-ehcache.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.0.xsd">
<!-- Root Context: defines shared resources visible to all other web components -->
</beans>
Run Code Online (Sandbox Code Playgroud)
如果我的申请中缺少jar文件,请告诉我.
这些是我在我的应用程序中唯一的jar文件:
displaytag-1.0-b3.jar,spring-2.0.6.jar,spring-asm-3.0.3.RELEASE.jar,spring-beans-3.0.3.RELEASE. jar,spring-context-3.0.3.RELEASE.jar,spring-core-3.0.3.RELEASE.jar,spring-expression-3.0.3.RELEASE.jar,spring-hibernate3-2.0.8.jar,spring- web-3.0.3.RELEASE.jar&spring-webmvc-3.0.3.RELEASE.jar
这是我的servlet-context.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->
<!-- Enables the Spring MVC …Run Code Online (Sandbox Code Playgroud) 我们能找到特定表的值,更新,删除或插入的历史记录吗?
我无权创建一个stored procedure.您能否在答案或其他方式中向我提供查询以查找历史记录?
这是我的ExcelController.java
public ModelAndView generateExcel(HttpServletRequest request,
HttpServletResponse response) {
// Created List called 'employeeList'
model.put("employeeList", employeeList);
return new ModelAndView("CreateExcel","employeeList",employeeList);
}
Run Code Online (Sandbox Code Playgroud)
这是我的ExcelRevenueReportView.java
protected void buildExcelDocument(Map<String, Object> model,
HSSFWorkbook workBook, HttpServletRequest request, HttpServletResponse response)
throws Exception {
@SuppressWarnings("unchecked")
List<Employee> employeeList = (List<Employee>) model.get("employeeList");
HSSFSheet sheet = workBook.createSheet("Employee List");
HSSFRow header = sheet.createRow(0);
header.createCell((short) 0).setCellValue("Employee");
int rowNum = 1;
for (Object employee : employeeList) {
//create the row data
HSSFRow row = sheet.createRow(rowNum++);
System.out.println(row);
row.createCell((short) 0).setCellValue(1);
}
}
Run Code Online (Sandbox Code Playgroud)
我的servlet.xml
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
</bean>
<bean …Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,我已将ApplicationContext xml文件放在src中,项目工作正常.
我们可以将它ApplicationContext.xml放在我们的WebContent或Web-Inf文件夹中吗?
另外我想知道我是否可以将我的属性文件放在WebContent中.
由于我已经放入ApplicationContext.xml了src,我将我的属性文件放在src中,并且工作正常.下面是它的代码
<bean id="licenseSettings"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:LicenseSettings.properties" />
</bean>
Run Code Online (Sandbox Code Playgroud)
我尝试将属性文件放入,WebContent/conf但未成功读取属性.
我的问题是,我们可以将ApplicationContext.xml和属性文件放在WebContent文件夹中的某个位置吗?
更新:我将我的ApplicationContext.xml放入其中WEB-INF/classes并使用它成功读取ApplicationContext ctx = new ClassPathXmlApplicationContext("ApplicationContext.xml");
我唯一没有答案的问题是,我应该在哪里放置我的属性文件以及哪里适合放入?
java ×7
spring ×6
spring-mvc ×5
file-upload ×1
jboss7.x ×1
meteor ×1
oracle ×1
sql ×1
tomcat ×1