我正在尝试将我的Java应用程序迁移到Spring Boot.目前,我正在使用Apache Tiles运行Spring MVC 3.2.当我迁移到Spring Boot时,我的控制器仍被调用,他们将视图传递给视图Resolver,但是当Tiles去拉JSP文件时,事情就会崩溃.我得到的错误信息是:
13:48:46,387 TRACE org.springframework.web.servlet.handler.SimpleUrlHandlerMapping:127 - No handler mapping found for [/jsp/layout/layout.jsp]
Run Code Online (Sandbox Code Playgroud)
有人在Spring Boot中成功使用过Apache Tiles吗?有什么想法怎么做?
提前感谢任何想法!
更多细节:
@Bean
public UrlBasedViewResolver viewResolver(){
LOGGER.trace("Entering tiles configurer");
UrlBasedViewResolver viewResolver = new UrlBasedViewResolver();
viewResolver.setViewClass(TilesView.class);
return viewResolver;
}
@Bean
public TilesConfigurer tilesConfigurer(){
LOGGER.trace("Entering tiles configurer");
System.out.println("Entering tiles configurer");
TilesConfigurer tilesConfigurer = new TilesConfigurer();
String[] defs = {"/WEB-INF/tiles-defs.xml"};
tilesConfigurer.setDefinitions(defs);
return tilesConfigurer;
}
Run Code Online (Sandbox Code Playgroud)
控制器:
@RequestMapping(value="/")
public ModelAndView index(ModelAndView mav, HttpServletRequest request, HttpServletResponse resp,RedirectAttributes ra){
LOGGER.trace("Arrived in Home Controller");
mav.addObject("profile",appContext.getEnvironment().getActiveProfiles()[0]);
mav.setViewName("home");
return mav;
} …Run Code Online (Sandbox Code Playgroud) 我正在为我的一位客户进行“主机标头注入”攻击。问题是,使用 Burp Suite,他们捕获请求并修改 Host 标头,如下所示。该应用程序是 Java Servlet,托管在 apache(Web 服务器)+ weblogic(应用程序服务器)上 原始请求
GET /myContext/testServlet?rq=home&tenId=123456 HTTP/1.1
Host: beta.testinglab.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Firefox/31.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Run Code Online (Sandbox Code Playgroud)
修改请求
GET /myContext/testServlet?rq=home&tenId=123456 HTTP/1.1
Host: www.google.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Firefox/31.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Run Code Online (Sandbox Code Playgroud)
在服务器端,即使在修改“主机标头”之后,请求也会提交到“beta.testinglab.com”,当我在服务器上使用时,request.getRequestUrl()它会给我“www.google.com”。无论如何,有没有办法找出所请求的原始主机是什么。该请求旨在纠正主机内部重定向问题。
我无法维护预定义的主机条目列表,因为该应用程序是由很多租户定制的。
有没有其他方法可以通过更改服务器配置来修复此攻击?
导入com.fasterxml.jackson.datatype无法解析
如屏幕截图所示,无法解析 import com.fasterxml.jackson.datatype 。
我已经在 build.gradle 中导入了 jackson-datatype-jsr310', version: '2.9.3,如下所示,
buildscript {
ext {
springBootVersion = '1.5.9.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
group = 'com.linkedin.learning'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-web')
runtime('com.h2database:h2')
testCompile('org.springframework.boot:spring-boot-starter-test')
// https://mvnrepository.com/artifact/com.fasterxml.jackson.datatype/jackson-datatype-jsr310
compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: '2.9.3'
}
Run Code Online (Sandbox Code Playgroud)
最后几行来自 Maven Repo:https://mvnrepository.com/artifact/com.fasterxml.jackson.datatype/jackson-datatype-jsr310/2.9.3
我想用的是
com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
Run Code Online (Sandbox Code Playgroud)
但是,即使是 com.fasterxml.jackson.datatype 也无法正确导入。
为了解决这个问题,我尝试在 build.gradle 中添加更多依赖项,正如这篇文章所建议的
首先抱歉.我知道它有很多相同的主题,但也许我的英语不好或者我找不到正确的答案.
我使用乐观锁定@Version注释.我需要从一个表中有一个一行有来自不同表的众多行,我确实插入了这样的:
所以它必须如下所示:
机构(这是我表中的一行(机构))
Run Code Online (Sandbox Code Playgroud)- CreationDate A (this is row from different table(CreationDate) bind with Institution with JoinTable, ManyToMany) - CreationDate B (this is row from different table(CreationDate) bind with Institution with JoinTable, ManyToMany) - CreationDate C (this is row from different table(CreationDate) bind with Institution with JoinTable, ManyToMany)
因此,为了使这个CreationDate具有不同的变化,我决定手动为我想要添加我的CreationDate的特定机构添加id.
我的主要方法类:
CreationDate crdate = new CreationDate();
Institution inst= new Institution();
Set<Institution> instituset = new HashSet<Institution>();
***inst.setInstitutionId(2);***
inst.setNameOfInstitution("MyInstitution");
inst.setTypeName("Education");
instituset.add(inst);
Run Code Online (Sandbox Code Playgroud)
当我想要附加到我的机构的另一行数据时,我在我的代码中添加了用星号标记的行.首先在数据库中插入我的版本行变为一行.
这是我的机构实体:
@Entity
@Table(name="INSTITUTION")
public class Institution implements Serializable{ …Run Code Online (Sandbox Code Playgroud) 在波斯语/阿拉伯语字符中,某些字符可选地位于其他字符的顶部或底部,例如 \xd9\x90 \xd9\x8e \xd9\x91 \xd9\x8f.
在我的例子中,如果我使用这个字符,indexOf找不到我的单词。认为波斯语/阿拉伯语是 RTL 语言。
\n\n例如:
\n\n\xd9\x85\xd9\x86\xd9\x91\xd9\x85 => \xd9\x85 + \xd9\x86 + \xd9\x91 + \xd9\x85\n\nC#:\n\n"\xd9\x85\xd9\x86\xd9\x91\xd9\x85".IndexOf("\xd9\x85\xd9\x86");\nreturn -1\n\njavascript:\nRun Code Online (Sandbox Code Playgroud)\n\n\xd9\x85\xd9\x86\xd9\x91\xd9\x85 => \xd9\x85 + \xd9\x86 + \xd9\x91 + \xd9\x85\n\nC#:\n\n"\xd9\x85\xd9\x86\xd9\x91\xd9\x85".IndexOf("\xd9\x85\xd9\x86");\nreturn -1\n\njavascript:\nRun Code Online (Sandbox Code Playgroud)\r\nC# 中发生了什么。任何人都可以解释这个吗?
\n我需要将数据从表行元素传递到菜单,但它只发送undefined数据。我用matMenuTriggerData这样的:
<ng-container matColumnDef="execute">
<th mat-header-cell fxFlex="8%" fxLayoutAlign="start center" *matHeaderCellDef></th>
<td mat-cell fxFlex="8%" fxLayoutAlign="start center" *matCellDef="let element">
<button mat-icon-button [matMenuTriggerFor]="menu" [matMenuTriggerData]="element">
<i class="material-icons" style="color: #368852">cloud_download</i>
</button>
</td>
</ng-container>
Run Code Online (Sandbox Code Playgroud)
和菜单:
<mat-menu #menu="matMenu">
<ng-template matMenuContent let-aliasMenuItems="element">
<button mat-menu-item (click)="cl(aliasMenuItems)">
<mat-icon>dialpad</mat-icon>
<span>Redial</span>
</button>
....
</mat-menu>
Run Code Online (Sandbox Code Playgroud)
我是Java泛型的新手.我写了一个如下函数:
public class C<T extends MyClass> implements MyInterface<T>{
public void f(T obj){
...
obj.getName()
}
}
Run Code Online (Sandbox Code Playgroud)
上面的函数f被调用两种类型的对象MySubClass1和MySubClass2.MySubClass1并且MySubClass2是从抽象类继承的两个concreter类MyClass,name是一个属性MySubClass2.
当用对象调用f时MySubClass2,我想访问上面的名字.我无法弄清楚如何做到这一点.