我正在创建宁静的Web服务,我想知道如何使用输入参数创建服务以及如何从Web浏览器调用它.
例如
@Path("/todo")
public class TodoResource {
// This method is called if XMLis request
@PUT
@Produces( {MediaType.APPLICATION_XML,MediaType.APPLICATION_JSON})
public Todo getXML() {
Todo todo = new Todo();
todo.setSummary("This is my first todo");
todo.setDescription("This is my first todo");
return todo;
}
Run Code Online (Sandbox Code Playgroud)
我可以使用http:// localhost:8088/JerseyJAXB/rest/todo调用它
我想创建一个类似的方法
@Path("/todo")
public class TodoResource {
// This method is called if XMLis request
@PUT
@Produces( {MediaType.APPLICATION_XML,MediaType.APPLICATION_JSON})
public Todo getXML(String x, String y) {
Todo todo = new Todo();
todo.setSummary(x);
todo.setDescription(y);
return todo;
}
Run Code Online (Sandbox Code Playgroud)
在基于肥皂的Web服务的情况下,我会像这样调用它
我在我的应用程序中使用Log4j并有一些调试和错误的appender.我在tomcat上测试了这个并且工作正常.生成各自文件中的所有日志.但是当我在WAS6.1上部署代码时,所有日志都只在SystemOut.log中生成.
请帮忙!
我有一个长期运行的线程,它是使用org.springframework.scheduling.commonj.WorkManagerTaskExecutor
Spring 创建的,并且在Websphere Application Server 8中运行.
问题是即使应用程序已停止,此线程仍会继续运行.该线程也需要停止,但它没有发生.我甚至试图用来 Thread.currentThread().isInterrupted()检查当前线程是否被中断,但它总是返回false.所以没有办法通过我的代码知道线程应该继续运行还是停止.
这是我对WorkManagerTaskExecutor的弹簧配置:
<bean id="taskExecutor" class="org.springframework.scheduling.commonj.WorkManagerTaskExecutor">
<property name="workManagerName" value="wm/default" />
</bean>
Run Code Online (Sandbox Code Playgroud)
线程正在以这种方式执行:
Thread t = new EmailReaderThread(email);
workManagerTaskExecutor.execute(t);
Run Code Online (Sandbox Code Playgroud)
我认为这不被视为非托管线程,因为我使用适当的WorkManager注册线程,容器由JNDI作为资源公开.
更新:这是创建线程的代码.
@Service
@Transactional
public class SmsServiceHypermedia implements SmsService {
@Autowired
private WorkManagerTaskExecutor workManagerTaskExecutor;
public SmsServiceHypermedia() {
createEmailReaderThread();
}
private void createEmailReaderThread() {
log.debug("Generating Email Reader Threads...");
Email email = getDefaultEmail(); //obtain the default Email object, not important for the problem.
EmailReaderThread r = new EmailReaderThread(email);
workManagerTaskExecutor.execute(r);
} …Run Code Online (Sandbox Code Playgroud) (来自SpringSource论坛.)
当HttpSession已经过期并且用户在流程中重新提交页面时,他/她被发送回流程的开头.我想要添加到此行为的所有内容都是一条消息,解释了它发生的原因."你没有活动,所以你已经重新启动......"
最简单/最佳实践方法是什么?
我有一个具有多个属性路径的实体.我使用Query By Example和ExampleMatcher忽略了一些属性路径.
我的实体如下所示,Employee.class
private Integer id;
private String name;
private String designation;
Run Code Online (Sandbox Code Playgroud)
我想只显示实体中的Name和Id(表中的字段).为此,我做了以下,
ExampleMatcher exampleMatcher = ExampleMatcher.matching().withIgnoreNullValues().withIgnorePaths("designation");
Example<Employee> example = Example.of(entity, exampleMatcher);
Run Code Online (Sandbox Code Playgroud)
但是,响应返回所有值,包括ignorePath中给出的属性.
请帮助我如何忽视物业路径.
我最近使用在AIX下运行的websphere和log4j接管了一个Web应用程序项目.为了创建开发环境,我在windows中设置了所有组件,使用eclipse编译WAR文件并进行部署.
除了没有创建日志文件外,一切正常.我更改了log4j.properties中的日志文件,如下所示,并为每个人提供对该目录的完全访问权限:
log4j.appender.F1.File=/abc/def/logs/admin.log
Run Code Online (Sandbox Code Playgroud)
至
log4j.appender.F1.File=c:/logs/admin.log
Run Code Online (Sandbox Code Playgroud)
我还能检查什么?
我创建了一个简单的独立测试应用程序,它使用相同的log4j.properties并且可以创建日志文件,但是当servlet部署到websphere时,它不起作用.请帮忙!谢谢!
我们正在构建新的休息服务。我有一个 PUT 方法,看起来像这样:
@RestController
public class RestController...
.
.
@PutMapping("/api/entity1")
public ResponseEntity<String> entity1Put(@RequestBody Myclass entity,
@RequestParam(value = "node1", defaultValue = emptyString) String node1,
@RequestParam(value = "user", defaultValue = emptyString) String user,
@RequestParam(value = "password", defaultValue = emptyString) String password) {...}
Run Code Online (Sandbox Code Playgroud)
该方法本质上是调用应用程序业务层的代理。我的 POST 方法将具有完全相同的签名、准备代码和返回类型。唯一的区别是业务层调用的方法的名称。为了减少代码并促进 API 一致性,我希望有一个方法可以同时处理 PUT 和 POST 请求。
是否有可能做到这一点?
@RestController
public class RestController...
.
.
@PutMapping("/api/entity1")
@PostMapping("/api/entity1")
public ResponseEntity<String> entity1PutandPost(@RequestBody Myclass entity,
@RequestParam(value = "node1", defaultValue = emptyString) String node1,
@RequestParam(value = "user", defaultValue = emptyString) String user,
@RequestParam(value …Run Code Online (Sandbox Code Playgroud) 首先,我们是Dojo的新手并且是以"新"的方式自由地做事,所以我大多忽略了文档的前1.7部分.不过,在比较各种文章,文档和示例脚本时,我会感到困惑.
最重要的是,我找不到关于如何为Dojo 创建和部署自定义构建的直截了当的说明.更具体地说,我们需要部署哪些.js和.css文件.有很多关于创建构建的文档,但是我在部署时没有找到.
我最终收集了将所有内容构建到单个dojo.js是一个合理的移动实践,我只需要从构建目录中提取一个文件并将其部署到我的服务器,但后来我得到了缺少的CSS引用,看起来好像试错法是解决这些问题的正确方法.
这是我们具体的当前案例:
<script type="text/javascript">
require(
// deviceTheme to auto-detect device styles
[
"dojox/mobile",
"dojox/mobile/parser",
"dojox/mobile/deviceTheme"
]);
</script>
Run Code Online (Sandbox Code Playgroud)
这是构建配置文件:
dependencies = {
stripConsole: "normal",
layers: [
{
name: "dojo.js",
customBase: true, // prevent automatic inclusion of dojo/main
dependencies: [
"dojox.mobile.parser",
"dojox.mobile",
"dojox.mobile.deviceTheme"
]
}
],
prefixes: [
[ "dijit", "../dijit" ], // example included; not clear why
[ "dojox", "../dojox" ]
]
}
Run Code Online (Sandbox Code Playgroud)
(由dojo-release-1.7.2-src\dojox\mobile\build\build.bat脚本执行.)
所以我想具体的问题是:
mobile-all.profile.js …无论是VelocityTools工具使用情况摘要,并在DateTool的Javadoc似乎表明用于设置时区的配置机制,但我根本无法发现那是什么.
DateTool的timezone setter是protected,我不想重复将TimeZone传递给重载format()方法.
(VelocityTools 2.0)
这是我的属性文件:
log4j.rootLogger=INFO, DATEDFILE, CONSOLE, DEBUG
### direct log messages to stdout ###
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
#log4j.appender.stdout.Target=System.out
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
log4j.appender.DATEDFILE=biz.minaret.log4j.DatedFileAppender
log4j.appender.DATEDFILE.layout=org.apache.log4j.PatternLayout
log4j.appender.DATEDFILE.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
log4j.appender.DATEDFILE.Prefix=arendeprocess.
log4j.appender.DATEDFILE.Suffix=.log
log4j.appender.DATEDFILE.Directory=//localhost/WebsphereLog/PandoraArendeWeb/
Run Code Online (Sandbox Code Playgroud)
我认为它应该使类别DEBUG日志,为什么不呢?
SecurityConfiguration 中的 SecurityFilterChain beans 返回此错误 我没有找到任何有关此方法的信息来解决该问题:
@Configuration
@EnableWebSecurity
public class SecurityConfiguration {
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity httpSecurity) throws Exception {
return httpSecurity
.csrf(csrf -> csrf.disable())
.sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
.authorizeHttpRequests(authorize -> authorize
.requestMatchers(HttpMethod.POST, "/auth/login").permitAll()
.requestMatchers(HttpMethod.POST, "/auth/register").permitAll()
.requestMatchers(HttpMethod.POST, "/product").hasRole("ADMIN")
.anyRequest().authenticated()
)
.build();
}
}
Run Code Online (Sandbox Code Playgroud)
引起:org.springframework.beans.BeanInstantiationException:无法实例化[org.springframework.security.web.SecurityFilterChain]:工厂方法“securityFilterChain”抛出异常并显示消息:此方法无法确定这些模式是否是Spring MVC模式。如果此端点是 Spring MVC 端点,请使用 requestMatchers(MvcRequestMatcher); 否则,请使用 requestMatchers(AntPathRequestMatcher)。
原因:java.lang.IllegalArgumentException:此方法无法确定这些模式是否是 Spring MVC 模式。如果此端点是 Spring MVC 端点,请使用 requestMatchers(MvcRequestMatcher); 否则,请使用 requestMatchers(AntPathRequestMatcher)。
spring-security spring-boot spring-framework-beans security-filter
java ×4
log4j ×3
websphere ×3
spring-boot ×2
spring-mvc ×2
commonj ×1
dojo ×1
dojox.mobile ×1
hibernate ×1
jax-rs ×1
jpa ×1
rest ×1
servlets ×1
spring ×1
spring-web ×1
threadpool ×1
velocity ×1
web-services ×1
websphere-ce ×1