私のアプリケーションにモバイルデバイスを検出させてそのページをレンダリングしようとしていますが、応答がありませんが、index.htmlページがレンダリングされています。私のモバイルコントローラは完全に無視されています。スプリングブートでモバイルデバイスを検出する
@Controller
public class DeviceDetection {
@RequestMapping("/")
public @ResponseBody String detectDevice(Device device) {
if (device.isNormal()) {
System.out.println("Inside isNormal()");
return "index";
} else if (device.isMobile()) {
System.out.println("Inside isMobile()");
return "mobilePage";
} else if (device.isTablet()) {
return "mobilePage";
}
return "index";
}
}
のpom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mobile</artifactId>
</dependency>
これは既に追加されています。申し訳ありませんが私の質問に追加することを忘れました – Drew1208
@ Drew1208私の答えを更新しました。 –
私は '@ RequestMapping'に/ indexを追加して動作させましたが、' mobilePage'という文字列をブラウザにレンダリングするだけです。私は 'resourceViewResolver'が必要だと思っていますが、わかりません。 – Drew1208